Skip to content

Commit 7a532aa

Browse files
committed
extension/src/goEnv: set GOTOOLCHAIN=auto by default
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 <[email protected]> kokoro-CI: kokoro <[email protected]> Reviewed-by: Robert Findley <[email protected]>
1 parent 4cd8eb1 commit 7a532aa

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

extension/src/goEnv.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ export function toolInstallationEnvironment(): NodeJS.Dict<string> {
4242
}
4343
env['GOPATH'] = toolsGopath;
4444

45+
// Explicitly set 'auto' so tools that require
46+
// a newer toolchain can be built.
47+
// We don't use unset, but unconditionally set this env var
48+
// since some users may change the env var using GOENV,
49+
// GOROOT/.goenv, or toolchain modification.
50+
env['GOTOOLCHAIN'] = 'auto';
51+
4552
// Unset env vars that would affect tool build process: 'GOROOT', 'GOOS', 'GOARCH', ...
4653
// Tool installation should be done for the host OS/ARCH (GOHOSTOS/GOHOSTARCH) with
4754
// the default setup.

0 commit comments

Comments
 (0)