-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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/go: always pass a GoVersion to cmd/vet #65612
Comments
We set the At any rate, that does seem to match what we do when we invoke the compiler: we also omit the flag in that case. This is kind of an unfortunate consequence of the property that files given on the command line are not considered to be part of a module (see https://go.dev/cl/339170). That also has some implications for, say, importing (CC @matloob @samthanawalla) |
With the range scope change, there are some tools (x/tools/go/ssa, nilness, staticcheck) that need a decision about what the GoVersion of a file is. ssa and vet were defaulting to unknown meant the earliest possible version, e.g. 1. That seemed like a backwards compatible direction at the time. The vet bug report was an inconsistency with the command line file name and the module. The loopclosure.Analyzer can be fixed to interpret "" as an 'unknown' version and can suppress these. ssa needs to choose a semantics though. Guessing the toolchain version for a file would produce inconsistent results between runs. (More likely to guess more up to date?)
+1 Feel free to pull me into the conversation as needed. |
I was trying to remove some of the It turns out that golangci-lint invokes go vet, and remains to report Any suggestions we can get rid of this in 1.22.0 release? |
@changkun I don't think this is directly related to this issue, and I will need to ask several follow-up questions. Please open a new issue and cc me. |
Some interesting thought-experiments to consider:
In discussing with @rsc, @matloob, and @samthanawalla, we're thinking maybe the thing to do for now is to use the language version from either the On the other hand, there is currently a special case for resolving imports of |
Any discussion for when you were thinking this should be done? Part of 1.22.1 ? If it is after, maybe we should update cmd/vet to use the same logic in the interim? Having vet differ from run seems like a bad state of affairs. |
Does vet differ from the compiler here? Presumably the go command passes the same version to both. If it does differ, why does it differ? |
I think the compiler defaults to the highest |
Change https://go.dev/cl/567435 mentions this issue: |
Change https://go.dev/cl/567635 mentions this issue: |
For Go >=1.22, FileVersions returns an unknown [invalid] Future version when the file versions would be invalid. This better matches go/types. For Go <=1.21, FileVersions returns either the runtime.Version() or the Future version. Adds AtLeast and Before for doing comparisons with Future. Updates golang/go#65612 Fixes golang/go#66007 Change-Id: I93ff1681b0f9117765614a20d82642749597307c Reviewed-on: https://go-review.googlesource.com/c/tools/+/567635 Reviewed-by: Robert Findley <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Tim King <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
Change https://go.dev/cl/591136 mentions this issue: |
Change https://go.dev/cl/593156 mentions this issue: |
For: #65612 Fixes: #66092 For now, we will align the behavior such that vet and the compiler agree that gover.Local() will be used for command-line-files. We expect to change this to set the goversion as the containing module's go version. Change-Id: If7f2ea3a82e8e876716f18dacc021026de175a93 Reviewed-on: https://go-review.googlesource.com/c/go/+/593156 Reviewed-by: Michael Matloob <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Sam Thanawalla <[email protected]>
Change https://go.dev/cl/593315 mentions this issue: |
Change https://go.dev/cl/593295 mentions this issue: |
This is fixed now. The GoVersion will always be passed for cmd/vet Created #68159 for changing which version will be passed for files listed on the command line going forward. |
Reported by @alexaandru in #63888 (comment)
No output (as expected) when running as a package:
False positive when running on a file:
go1.22.0 vet -x -json example.com/m
gives the GoVersion as"GoVersion": "go1.22.0",
.go1.22.0 vet -x -json main.go
gives the GoVersion as"GoVersion": "",
.@bcmills
The text was updated successfully, but these errors were encountered: