Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go/doc: methods on type error are shown in docs #9860

Closed
tv42 opened this issue Feb 13, 2015 · 7 comments
Closed

go/doc: methods on type error are shown in docs #9860

tv42 opened this issue Feb 13, 2015 · 7 comments
Milestone

Comments

@tv42
Copy link

tv42 commented Feb 13, 2015

Something in this source is making godoc.org do weird things: http://godoc.org/github.com/alphazero/contextual

First guess would be this: https://github.com/alphazero/contextual/blob/1d18e8ac42a5e6e2e65dc02f44b93e48c8170bce/contextual.go#L30

type error struct {
    msg string
}

Here's the index as it shows up right now:

Index
Constants
func ChildContext(p *context) (c *context, e Error)
func (e error) Error() string
func (e error) Is(errmsg string) bool
func NewContext() *context
type Component
func NewComponent() Component
type Container
type Context
type Contextual
type Error

Now, that source is silly but this still sounds like a bug in godoc.org.

@tv42
Copy link
Author

tv42 commented Feb 13, 2015

Migrated to golang/gddo#244, sorry for the noise.

@tv42 tv42 closed this as completed Feb 13, 2015
@adg adg changed the title godoc.org: "type error struct {...}" makes Index list methods of the type tools/cmd/godoc:: methods on type error are shown in docs Feb 13, 2015
@adg
Copy link
Contributor

adg commented Feb 13, 2015

If you declare a type named error (a bad idea) then godoc shows its methods:

~/src/test $ cat test.go
package test

type error struct{}

func (error) F() {}
$ godoc test
PACKAGE DOCUMENTATION

package test
    import "test"

FUNCTIONS

func (error) F()

@adg adg reopened this Feb 13, 2015
@adg adg changed the title tools/cmd/godoc:: methods on type error are shown in docs go/doc:: methods on type error are shown in docs Feb 13, 2015
@adg adg changed the title go/doc:: methods on type error are shown in docs go/doc: methods on type error are shown in docs Feb 13, 2015
@josharian
Copy link
Contributor

@adg sorry for being slow, but why is this not working as intended?

@adg
Copy link
Contributor

adg commented Feb 18, 2015

@josharian the package-level error type is not exported, so its methods should not be visible in the package docs.

@griesemer griesemer added the godoc label Apr 1, 2015
@rsc rsc removed the godoc label Apr 10, 2015
@rsc rsc added this to the Go1.5 milestone Apr 10, 2015
@rsc rsc modified the milestones: Go1.6, Go1.5 Jul 15, 2015
@rsc rsc modified the milestones: Go1.7Early, Go1.6 Jan 6, 2016
@gopherbot
Copy link

CL https://golang.org/cl/20610 mentions this issue.

@larzconwell
Copy link
Contributor

I made an easy fix for this. go/doc simply drops any methods defined on locally-declared predeclared types, since the types are never exported its methods should never be visible(unless AllDecls is given, of course).

@bradfitz bradfitz modified the milestones: Go1.7Maybe, Go1.7Early May 6, 2016
@rsc
Copy link
Contributor

rsc commented May 17, 2016

@griesemer, I added you as a reviewer to CL 20610. Please make a decision for Go 1.7. Thanks.

@rsc rsc modified the milestones: Go1.8, Go1.7Maybe May 27, 2016
@golang golang locked and limited conversation to collaborators Oct 6, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants