src/goMain.ts: reinstate the goroot var interpolation
Add back the feature that resolves ~, ${workspaceFolder},
${workspaceRoot} included in "go.goroot". This feature was available
since 0.6.72, but accidentally lost during the 0.15 dev cycle
when we restructured the handling of `GOROOT`.
Fixes golang/vscode-go#464
Change-Id: I373cdc8de02d3d1764ca939b6ca6299216a6496e
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/246518
Reviewed-by: Brayden Cloud <bcloud@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/src/goMain.ts b/src/goMain.ts
index 4bc637d..664d459 100644
--- a/src/goMain.ts
+++ b/src/goMain.ts
@@ -58,7 +58,8 @@
getToolsGopath,
getWorkspaceFolderPath,
handleDiagnosticErrors,
- isGoPathSet
+ isGoPathSet,
+ resolvePath,
} from './util';
import { clearCacheForTools, envPath, fileExists, getCurrentGoRoot, setCurrentGoRoot } from './utils/goPath';
@@ -78,7 +79,7 @@
const configGOROOT = getGoConfig()['goroot'];
if (!!configGOROOT) {
- setCurrentGoRoot(configGOROOT);
+ setCurrentGoRoot(resolvePath(configGOROOT));
}
updateGoVarsFromConfig().then(async () => {
diff --git a/src/util.ts b/src/util.ts
index e29245f..23b7f59 100644
--- a/src/util.ts
+++ b/src/util.ts
@@ -484,7 +484,7 @@
return getBinPathWithPreferredGopathGoroot(
tool,
tool === 'go' ? [] : [getToolsGopath(), getCurrentGoPath()],
- tool === 'go' && cfg.get('goroot') ? cfg.get('goroot') : undefined,
+ tool === 'go' && cfg.get('goroot') ? resolvePath(cfg.get('goroot')) : undefined,
selectedGoPath ?? resolvePath(alternateToolPath),
useCache
);