-
Notifications
You must be signed in to change notification settings - Fork 819
How to make 1.22.9 workspaces work on Ubuntu 24.04 #3622
-
We have a workspace with multiple modules. All are defined as using golang 1.22.9.
Now in a module, the extension wants to analyze the encompassing workspace.
It seems to do this with the system Go toolchain :( (which is 1.22.2).
As a result it prints a lot of errors:
packages.Load error: err: exit status 1: stderr: go: go.work requires go >= 1.22.9 (running go 1.22.2)
What must I configure so that it uses another toolchain?
And by the way - is there a way of preventing/disallowing it to use the system Golang toolchain? It almost never is correct to use that.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
@AndreasBergmeier6176
I think I see what’s happening here. Your workspace is set up to use Go 1.22.9, but the extension is picking up the system-installed Go version 1.22.2, which is causing all these errors.
To fix this, you’ll want to make sure your environment is correctly set up so that the right Go version is used everywhere. A good way to do this is by setting GOTOOLCHAIN=local
, which tells Go to always use the version specified in your workspace rather than falling back to the system toolchain. You can do this by running (from your workspace):
go env -w GOTOOLCHAIN=local
Or:
go env -w GOTOOLCHAIN=go1.22.9
Also, make sure your go.work
file correctly specifies go 1.22.9, which I assume is already the case.
In VS Code, the extension might still be defaulting to the system Go installation. You can force it to use the correct version by setting the GOROOT path in the settings, or adding this to your settings.json:
"go.alternateTools": { "go": "/path/to/go1.22.9/bin/go" }
That should sort it out. Let me know if it still gives you trouble
Beta Was this translation helpful? Give feedback.