-
Notifications
You must be signed in to change notification settings - Fork 796
staticcheck and other tools aren't compiled correctly when auto-downloading Go 1.22 #3168
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
Comments
This has been causing me problems all across my repo. |
The root cause for the issue in my case was I had Go installed via Uninstalling Go via |
Fix that ended up working for me was editing my Then restarting vs code and allowing it to download the new toolchain |
@michal-kra thanks For resolve this issue:
|
this update on go.mod @kfelter worked for me. Weirdly, in my go.mod there was 1.23 somehow. |
different golang tools want go.mod to use format 1.22.1 others demand format 1.22 this is root cause of this bug and many others surrounding go tooling |
Change https://go.dev/cl/577095 mentions this issue: |
Change https://go.dev/cl/583975 mentions this issue: |
CL 577095 https://go-review.googlesource.com/c/vscode-go/+/577095 made a change to compute the go version used for tools installation using `GOTOOLCHAIN=local go version`. However, that's not sufficient. There is a go version cache (cachedGoVersion) and if the go binary path is same, getGoVersion uses the cachedGoVersion. But after go1.21 this assumption doesn't hold because the same go binary can return different go version depending on its toolchain switch mode. For now, skip caching if getGoVersion is called with non-default GOTOOLCHAIN param. We use this mode of getGoVersion only during tool installation, which is supposed to be rare. For #3168 Change-Id: Id33536d70b74afee592e4a98bd59865e41dbea49 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/583975 Commit-Queue: Hyang-Ah Hana Kim <[email protected]> kokoro-CI: kokoro <[email protected]> Reviewed-by: Suzy Mueller <[email protected]>
What version of Go, VS Code & VS Code Go extension are you using?
Version Information
go version
to get version of Go from the VS Code integrated terminal.go version go1.22.0 linux/amd64
when inside the project directory, otherwisego version go1.21.7 linux/amd64
gopls -v version
to get version of Gopls from the VS Code integrated terminal.code -v
orcode-insiders -v
to get version of VS Code or VS Code Insiders.Go: Locate Configured Go Tools
command.Share the Go related settings you have added/edited
I don't have any Go settings set in settings.json.
Describe the bug
I have Go 1.21.7 installed via Hombrew, and opened a project with a go.mod that declares
go 1.22.0
. This caused Go to automatically download the newer toolchain and use it when running the program. But when I runstaticcheck
I get an immediate crash because it hasn't been recompiled for Go 1.22. The VS code extension shows the prompt "Tools (gopls, gotests, gomodifytags, impl, goplay, dlv, staticcheck) need recompiling to work with go version go1.22.0 linux/amd64", but clicking on the "Update tools" button just recompiles them with Go 1.21.7 and not 1.22.0, so it still doesn't work. Ideally the VS code extension should be able to recompile the tools using the right version of Go, i.e./home/user/go/pkg/mod/golang.org/[email protected]/bin/go
instead of the version that's on the PATH.Steps to reproduce the behavior:
go.mod
that declaresgo 1.22.0
staticcheck ./...
will produce crashes such asScreenshots or recordings
If applicable, add screenshots or recordings to help explain your problem.
The text was updated successfully, but these errors were encountered: