Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
Look for Go tools in GOBIN as well (#3001)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcel-basel authored Jan 28, 2020
1 parent 8f00179 commit fbb180d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/goInstallTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,12 @@ export function installTools(missing: Tool[], goVersion: GoVersion): Promise<voi
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,
Expand Down
6 changes: 6 additions & 0 deletions src/goPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ export function getBinPathWithPreferredGopath(toolName: string, preferredGopaths
}

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
Expand Down

0 comments on commit fbb180d

Please sign in to comment.