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

x/tools/cmd/godoc: godoc shows initializers for unexported fields #11758

Closed
mdempsky opened this issue Jul 17, 2015 · 2 comments
Closed

x/tools/cmd/godoc: godoc shows initializers for unexported fields #11758

mdempsky opened this issue Jul 17, 2015 · 2 comments
Milestone

Comments

@mdempsky
Copy link
Member

http://tip.golang.org/pkg/go/types/#pkg-variables:

var Typ = [...]*Basic{
    Invalid: {Invalid, 0, "invalid type"},
    [...]
}

http://tip.golang.org/pkg/go/types/#Basic:

type Basic struct {
    // contains filtered or unexported fields
}

It seems somewhat inconsistent that godoc would hide unexported fields from the Basic type description, but then show the values used to initialize them within Typ. It's not legal for users to write types.Basic{types.Invalid, 0, "invalid type"}.

@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Jul 17, 2015
@rsc
Copy link
Contributor

rsc commented Nov 5, 2015

In general godoc shows the initializers unmodified. It is up to the code author to put something useful there (or not). In this case if the definition of Typ should be hidden then the idiom is

var Typ [...]*Basic = basicTypes

var basicTypes = [...]*Basic{...}

@rsc
Copy link
Contributor

rsc commented Nov 5, 2015

That is, I don't think this is a bug in godoc.

@rsc rsc closed this as completed Nov 5, 2015
@golang golang locked and limited conversation to collaborators Nov 4, 2016
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

5 participants