Skip to content

proposal: go/doc: consts/vars should be grouped with types by their computed type #22918

@willfaught

Description

@willfaught

Currently, constant and variable declarations must have an explicit type to be grouped with that type. For example, go/build.Context is declared like var Default Context = defaultContext(), with an explicit Context type, because otherwise Default wouldn't be listed under the Context type.

If you add an explicit type, and the type can be inferred from the right-hand side of the assignment, then golint complains about the redundant explicit type.

If the Context type was missing from the Default declaration, it would be impossible to know for sure what type it is, since defaultContext isn't exported. (Okay, maybe you could guess in this situation, but what if it was called getDefault instead?)

We should instead compute a const/var declaration's type with the type checker and group them in doc accordingly.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions