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

Commit

Permalink
Expands ${workspaceRoot} in go.toolsGopath configuration (#759)
Browse files Browse the repository at this point in the history
Fixes #761
  • Loading branch information
vanackere authored and ramya-rao-a committed Feb 3, 2017
1 parent 495dda1 commit e4e7eb1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/goInstallTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import cp = require('child_process');
import { showGoStatus, hideGoStatus } from './goStatus';
import { getGoRuntimePath } from './goPath';
import { outputChannel } from './goStatus';
import { getBinPath, getGoVersion, SemVersion, isVendorSupported } from './util';
import { getBinPath, getToolsGopath, getGoVersion, SemVersion, isVendorSupported } from './util';

let updatesDeclinedTools: string[] = [];

Expand Down Expand Up @@ -142,10 +142,10 @@ function installTools(goVersion: SemVersion, missing?: string[]) {

// If the go.toolsGopath is set, use
// its value as the GOPATH for the "go get" child process.
let goConfig = vscode.workspace.getConfiguration('go');
let toolsGopath = getToolsGopath();
let envWithSeparateGoPathForTools = null;
if (goConfig['toolsGopath']) {
envWithSeparateGoPathForTools = Object.assign({}, envForTools, {GOPATH: goConfig['toolsGopath']});
if (toolsGopath) {
envWithSeparateGoPathForTools = Object.assign({}, envForTools, {GOPATH: toolsGopath});
}

missing.reduce((res: Promise<string[]>, tool: string) => {
Expand Down
15 changes: 12 additions & 3 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,16 @@ export function isPositionInString(document: vscode.TextDocument, position: vsco
return doubleQuotesCnt % 2 === 1;
}

export function getBinPath(tool: string): string {
export function getToolsGopath(): string {
let goConfig = vscode.workspace.getConfiguration('go');
return getBinPathWithPreferredGopath(tool, goConfig['toolsGopath']);
}
let toolsGopath = goConfig['toolsGopath'];
if (toolsGopath) {
toolsGopath = toolsGopath.replace(/\${workspaceRoot}/g, vscode.workspace.rootPath);
}
return toolsGopath;
}

export function getBinPath(tool: string): string {
return getBinPathWithPreferredGopath(tool, getToolsGopath());
}

0 comments on commit e4e7eb1

Please sign in to comment.