Skip to content

Commit

Permalink
extension/src/goEnv: set GOTOOLCHAIN=auto by default
Browse files Browse the repository at this point in the history
After go1.21, the tool authors can specify their go version
requirements in their go.mod files. Gopls v0.17+ will start
to require the latest go version. The `go install` command
will then try to download the required go version if the
local toolchain is not new enough to meet the requirement.

Some users set GOTOOLCHAIN to local to avoid toolchain update
during their own projects build. If the local toolchain is
older than the latest go, tool installation will stop working.
The users' intention is most likely to control the go version
used to build their own projects, not the tools the plugin
depends on though.

Override the env var to the official toolchain's default
"auto".

Fixes #3430

Change-Id: I708ec88001b40e7b5dcd47365083e7530d1d7eab
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/596315
Commit-Queue: Hyang-Ah Hana Kim <hyangah@gmail.com>
kokoro-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
  • Loading branch information
hyangah committed Jul 8, 2024
1 parent 4cd8eb1 commit 7a532aa
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions extension/src/goEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ export function toolInstallationEnvironment(): NodeJS.Dict<string> {
}
env['GOPATH'] = toolsGopath;

// Explicitly set 'auto' so tools that require
// a newer toolchain can be built.
// We don't use unset, but unconditionally set this env var
// since some users may change the env var using GOENV,
// GOROOT/.goenv, or toolchain modification.
env['GOTOOLCHAIN'] = 'auto';

// Unset env vars that would affect tool build process: 'GOROOT', 'GOOS', 'GOARCH', ...
// Tool installation should be done for the host OS/ARCH (GOHOSTOS/GOHOSTARCH) with
// the default setup.
Expand Down

0 comments on commit 7a532aa

Please sign in to comment.