Skip to content

cmd/doc: support 'go doc package@version' syntax #63696

Description

@adonovan

The go doc command displays documentation for packages in the workspace, but it would be very useful if it also worked on packages (and commands in particular) that are not part of the workspace, using an @version suffix. The implementation would consult the module cache, populating it as needed. For example:

$ go doc go.starlark.net/syntax@latest
go: downloading go.starlark.net v0.0.0-20231016134836-22325403fcb3
go: added go.starlark.net v0.0.0-20231016134836-22325403fcb3
package syntax // import "go.starlark.net/syntax"

Package syntax provides a Starlark parser and abstract syntax tree.
...

@rsc made the suggestion that the version suffix could be inferred if the package name was not part of the workspace, if it matched the name of a command on $PATH, and that command was a Go executable, and the metadata inside that Go executable provided a module@version provenance string.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status
    Accepted

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions