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

feat: allow workspaceFolder substition in go.alternateTools #2544

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/goPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ export function getBinPathFromEnvVar(toolName: string, envVarValue: string, appe
return null;
}

export function getBinPathWithPreferredGopath(toolName: string, preferredGopaths: string[], alternateTools?: { [key: string]: string; }) {
export function getBinPathWithPreferredGopath(toolName: string, preferredGopaths: string[], alternateTool?: string) {
if (binPathCache[toolName]) return binPathCache[toolName];

const alternateTool = (alternateTools && alternateTools[toolName]) ? resolveHomeDir(alternateTools[toolName]) : null;
if (alternateTool && path.isAbsolute(alternateTool) && fileExists(alternateTool)) {
binPathCache[toolName] = alternateTool;
return alternateTool;
Expand Down
9 changes: 8 additions & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,14 @@ function resolveToolsGopath(): string {
}

export function getBinPath(tool: string): string {
return getBinPathWithPreferredGopath(tool, (tool === 'go') ? [] : [getToolsGopath(), getCurrentGoPath()], vscode.workspace.getConfiguration('go', null).get('alternateTools'));
const alternateTools: {[key: string]: string} = vscode.workspace.getConfiguration('go', null).get('alternateTools');
const alternateToolPath: string = alternateTools[tool];

return getBinPathWithPreferredGopath(
tool,
(tool === 'go') ? [] : [getToolsGopath(), getCurrentGoPath()],
resolvePath(alternateToolPath),
);
}

export function getFileArchive(document: vscode.TextDocument): string {
Expand Down