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

Commit

Permalink
Also use GOROOT/bin as a fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
lukehoban committed Nov 20, 2015
1 parent 0f20bc6 commit 72ef57a
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/goPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ import { showGoStatus, hideGoStatus } from './goStatus'
var binPathCache : { [bin: string]: string;} = {}

export function getBinPath(binname) {
if(binPathCache[binname]) return binPathCache[binname];
binname = correctBinname(binname);
var binpath: string;
if(binPathCache[binname]) return binPathCache[binname];

// First search each GOPATH workspace's bin folder
var workspaces = getPathParts(process.env["GOPATH"]);
for(var i = 0; i < workspaces.length; i++) {
binpath = path.join(workspaces[i], "bin", binname);
let binpath = path.join(workspaces[i], "bin", binname);
if(fs.existsSync(binpath)) {
binPathCache[binname] = binpath;
return binpath;
Expand All @@ -31,7 +30,16 @@ export function getBinPath(binname) {
// Then search PATH parts
var pathparts = getPathParts(process.env["PATH"]);
for(var i = 0; i < pathparts.length; i++) {
binpath = path.join(pathparts[i], binname);
let binpath = path.join(pathparts[i], binname);
if(fs.existsSync(binpath)) {
binPathCache[binname] = binpath;
return binpath;
}
}

// Finally check GOROOT just in case
{
let binpath = path.join(process.env["GOROOT"], "bin", binname);
if(fs.existsSync(binpath)) {
binPathCache[binname] = binpath;
return binpath;
Expand Down

0 comments on commit 72ef57a

Please sign in to comment.