Skip to content

x/tools/godoc: may show Go version when an identifier was modified rather than originally added #44081

Closed
@dmitshur

Description

@dmitshur

godoc (and in turn, https://golang.org/pkg/) displays next to identifiers the version of Go when said identifier was added. This was #5778.

As reported by @benhoyt in a golang-dev thread, godoc may sometimes show that an identifier was added in a Go version too new.

This happens when a signature is modified in a later Go version. For example, the os.Chmod function was added in Go 1 and appears in api/go1.txt as:

pkg os, func Chmod(string, FileMode) error

In Go 1.16, the os.FileMode type was modified (in an API compatible way: it became a type alias to fs.FileMode), causing os.Chmod to show up in api/go1.16.txt:

pkg os, func Chmod(string, fs.FileMode) error

(As far as I can tell from aliasReplacer and its comment, added to cmd/api by @rsc in CL 243906, the api file content is working as intended; please comment otherwise.)

The fix in godoc is to look for the earliest api/go*.txt file where an identifier was mentioned. I'll send a CL.

CC @ianlancetaylor, @julieqiu.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.ToolsThis label describes issues relating to any tools in the x/tools repository.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions