You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cmd/vet: consider reporting invalid/ignored Go versions in build tags #64127
Files may specify their own Go language version via a build tag. For instance:
//go:build go1.22
indicates that this file requires Go language version 1.22.
If the language version in the build tag contains dot-release information, say it's "go1.22.1", it is invalid.
The compiler simply ignores the version (it doesn't use, say "go1.22").
It seems (to me) that this shouldn't be silently ignored as it might be very confusing for users. go vet might be the right tool to report an error. Alternatively, the compiler could report an error, but generally, the compiler doesn't complain about errors in (pragma and build) comments.
It should report any Go version string that is silently dropped and ignored.
Also, before anybody starts working on this: note this is a proposal and needs to be discussed by the proposal review committee first. Thanks.
This proposal has been added to the active column of the proposals project
and will now be reviewed at the weekly proposal review meetings.
— rsc for the proposal review group
A new check added to vet seems like something that needs to be mentioned in Go 1.24 release notes, and it's not mentioned there yet. Reopening as a release blocker for tracking that.
Activity
timothy-king commentedon Nov 14, 2023
go/analysis/passes/buildtag would be a good home for this check.
Goclipse27 commentedon Nov 15, 2023
Goclipse27 commentedon Nov 16, 2023
@griesemer @ianlancetaylor - Do you consider handling tags including expression like go:build go1.21 && go1.22.3 or a single tag ?
Goclipse27 commentedon Nov 16, 2023
griesemer commentedon Nov 16, 2023
It should report any Go version string that is silently dropped and ignored.
Also, before anybody starts working on this: note this is a proposal and needs to be discussed by the proposal review committee first. Thanks.
rsc commentedon May 30, 2024
We already have a //go:build line checker. It should definitely report these.
rsc commentedon May 30, 2024
This proposal has been added to the active column of the proposals project
and will now be reviewed at the weekly proposal review meetings.
— rsc for the proposal review group
rsc commentedon Jun 5, 2024
No change in consensus, so accepted. 🎉
This issue now tracks the work of implementing the proposal.
— rsc for the proposal review group
The proposal is for the ‘buildtag’ checker to report build tags of the form go1.X.Y since only go1.X is recognized in build tags.
5 remaining items
dmitshur commentedon Nov 26, 2024
A new check added to vet seems like something that needs to be mentioned in Go 1.24 release notes, and it's not mentioned there yet. Reopening as a release blocker for tracking that.
gopherbot commentedon Nov 27, 2024
Change https://go.dev/cl/632355 mentions this issue:
doc/next: document buildtag changesdoc/next: document buildtag changes
go/analysis/passes/buildtag: report invalid go versions in build tags.