Skip to content

Commit 5d8af43

Browse files
committed
extension/src/util: do not use cached go version with GOTOOLCHAIN
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]>
1 parent f907536 commit 5d8af43

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

extension/src/util.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export async function getGoVersion(goBinPath?: string, GOTOOLCHAIN?: string): Pr
180180
if (!goRuntimePath) {
181181
throw error(`unable to locate "go" binary in GOROOT (${getCurrentGoRoot()}) or PATH (${getEnvPath()})`);
182182
}
183-
if (cachedGoBinPath === goRuntimePath && cachedGoVersion) {
183+
if (GOTOOLCHAIN === undefined && cachedGoBinPath === goRuntimePath && cachedGoVersion) {
184184
if (cachedGoVersion.isValid()) {
185185
return Promise.resolve(cachedGoVersion);
186186
}
@@ -205,7 +205,7 @@ export async function getGoVersion(goBinPath?: string, GOTOOLCHAIN?: string): Pr
205205
} catch (err) {
206206
throw error(`failed to run "${goRuntimePath} version": ${err} cwd: ${cwd}`);
207207
}
208-
if (!goBinPath && !GOTOOLCHAIN) {
208+
if (!goBinPath && GOTOOLCHAIN === undefined) {
209209
// if getGoVersion was called with a given goBinPath or an explicit GOTOOLCHAIN env var, don't cache the result.
210210
cachedGoBinPath = goRuntimePath;
211211
cachedGoVersion = goVersion;

0 commit comments

Comments
 (0)