-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Closed
Milestone
Description
For #61174, it would be good for individual checkers to be able to find out the Go version associated with a given package. The code will start tracking this, but we should export it as well. Strictly speaking this is not necessary for Go 1.21, but I suggest we include it now, since it will be necessary for Go 1.22 and it will be easier for tool authors if all the related changes are in the same Go version.
The new method is:
// GoVersion returns the minimum Go version required by this package.
// If the minimum version is unknown, GoVersion returns the empty string.
// Individual source files may specify a different minimum Go version,
// as reported in the [go/ast.File.GoVersion] field.
func (pkg *Package) GoVersion() string { return pkg.goVersion }
The goVersion is set during type-checking, copied from Config.GoVersion.
adonovan, findleyr, dominikh and woody1872