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

Commit

Permalink
Use getBinPath for VSCODE_GOTOOLS instead of modifying GOPATH
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Herrmann committed Jun 6, 2016
1 parent dd3a2fe commit 158949d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
10 changes: 2 additions & 8 deletions src/goInstallTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import { showGoStatus, hideGoStatus } from './goStatus';
import { getBinPath } from './goPath';

let channel = vscode.window.createOutputChannel('Go');
let toolsGoPath = process.env['VSCODE_GOTOOLS'];


let tools: { [key: string]: string } = {
gorename: 'golang.org/x/tools/cmd/gorename',
gopkgs: 'github.com/tpng/gopkgs',
Expand All @@ -34,6 +33,7 @@ export function installTool(tool: string) {

// If the VSCODE_GOTOOLS environment variable is set, use
// its value as the GOPATH for the "go get" child precess.
let toolsGoPath = process.env['VSCODE_GOTOOLS'];
let env = Object.assign({}, process.env);
if(toolsGoPath) {
env['GOPATH'] = toolsGoPath;
Expand Down Expand Up @@ -68,12 +68,6 @@ export function setupGoPathAndOfferToInstallTools() {
});
return;
}

// If the VSCODE_GOTOOLS environment variable is set,
// append its value to the process' GOPATH.
if(toolsGoPath) {
process.env['GOPATH'] = process.env['GOPATH'] + path.delimiter + toolsGoPath;
}

let keys = Object.keys(tools);
Promise.all(keys.map(tool => new Promise<string>((resolve, reject) => {
Expand Down
11 changes: 10 additions & 1 deletion src/goPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@ export function getBinPath(binname: string) {
binname = correctBinname(binname);
if (binPathCache[binname]) return binPathCache[binname];

// First search each GOPATH workspace's bin folder
// First check VSCODE_GOTOOLS' bin folder
if (process.env['VSCODE_GOTOOLS']) {
let binpath = path.join(process.env['VSCODE_GOTOOLS'], 'bin', binname);
if (fs.existsSync(binpath)) {
binPathCache[binname] = binpath;
return binpath;
}
}

// Then search each GOPATH workspace's bin folder
if (process.env['GOPATH']) {
let workspaces = process.env['GOPATH'].split(path.delimiter);
for (let i = 0; i < workspaces.length; i++) {
Expand Down

0 comments on commit 158949d

Please sign in to comment.