-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/vet: consider reporting invalid/ignored Go versions in build tags #64127
Comments
go/analysis/passes/buildtag would be a good home for this check. |
This comment was marked as off-topic.
This comment was marked as off-topic.
@griesemer @ianlancetaylor - Do you consider handling tags including expression like go:build go1.21 && go1.22.3 or a single tag ? |
This comment was marked as resolved.
This comment was marked as resolved.
It should report any Go version string that is silently dropped and ignored. |
We already have a //go:build line checker. It should definitely report these. |
This proposal has been added to the active column of the proposals project |
No change in consensus, so accepted. 🎉 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. |
Change https://go.dev/cl/597576 mentions this issue: |
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. |
Change https://go.dev/cl/632355 mentions this issue: |
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.The text was updated successfully, but these errors were encountered: