Description
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.