Skip to content

cmd/go: go doc's -short flag has no effect when given a symbol selector #77192

@cespare

Description

@cespare

Go version

go version go1.25.1 linux/amd64

Output of go env in your module/workspace:

not relevant

What did you do?

I ran go doc -short runtime/metrics.Read.

What did you see happen?

I got the exact same output as go doc runtime/metrics.Read, minus the package declaration at the top.

▶ go doc -short runtime/metrics.Read
func Read(m []Sample)
    Read populates each Value field in the given slice of metric samples.

    Desired metrics should be present in the slice with the appropriate name.
    The user of this API is encouraged to re-use the same slice between calls
    for efficiency, but is not required to do so.

    Note that re-use has some caveats. Notably, Values should not be read
    or manipulated while a Read with that value is outstanding; that is a
    data race. This property includes pointer-typed Values (for example,
    Float64Histogram) whose underlying storage will be reused by Read when
    possible. To safely use such values in a concurrent setting, all data must
    be deep-copied.

    It is safe to execute multiple Read calls concurrently, but their arguments
    must share no underlying memory. When in doubt, create a new []Sample from
    scratch, which is always safe, though may be inefficient.

    Sample values with names not appearing in All will have their Value
    populated as KindBad to indicate that the name is unknown.

What did you expect to see?

I want a single line of output, since go doc -h promises:

  -short
        one-line representation for each symbol

So I'd expect something like:

▶ go doc -short runtime/metrics.Read
func Read(m []Sample)

I also filed an issue for a possibly-related -short bug at #77191.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixPendingIssues that have a fix which has not yet been reviewed or submitted.GoCommandcmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.help wanted

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions