Look for Go tools in GOBIN as well (#3001)
diff --git a/src/goInstallTools.ts b/src/goInstallTools.ts
index b1e095f..93b42e9 100644
--- a/src/goInstallTools.ts
+++ b/src/goInstallTools.ts
@@ -144,9 +144,12 @@
return;
}
- let installingMsg = `Installing ${missing.length} ${missing.length > 1 ? 'tools' : 'tool'} at ${toolsGopath}${
- path.sep
- }bin`;
+ let installingMsg = `Installing ${missing.length} ${missing.length > 1 ? 'tools' : 'tool'} at `;
+ if (envForTools['GOBIN']) {
+ installingMsg += `the configured GOBIN: ${envForTools['GOBIN']}`;
+ } else {
+ installingMsg += toolsGopath + path.sep + 'bin';
+ }
// If the user is on Go >= 1.11, tools should be installed with modules enabled.
// This ensures that users get the latest tagged version, rather than master,
diff --git a/src/goPath.ts b/src/goPath.ts
index caf40bb..cd89eea 100644
--- a/src/goPath.ts
+++ b/src/goPath.ts
@@ -41,6 +41,12 @@
}
const binname = alternateTool && !path.isAbsolute(alternateTool) ? alternateTool : toolName;
+ const pathFromGoBin = getBinPathFromEnvVar(binname, process.env['GOBIN'], false);
+ if (pathFromGoBin) {
+ binPathCache[toolName] = pathFromGoBin;
+ return pathFromGoBin;
+ }
+
for (const preferred of preferredGopaths) {
if (typeof preferred === 'string') {
// Search in the preferred GOPATH workspace's bin folder