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

Fail with better error messages if go binary cannot be found #1543

Merged
merged 1 commit into from
Feb 28, 2018
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: 3 additions & 0 deletions src/goInstallTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ export function updateGoPathGoRootFromConfig(): Promise<void> {

// If GOPATH is still not set, then use the one from `go env`
let goRuntimePath = getGoRuntimePath();
if (!goRuntimePath) {
return Promise.reject(new Error('Cannot find "go" binary. Update PATH or GOROOT appropriately'));
}
return new Promise<void>((resolve, reject) => {
cp.execFile(goRuntimePath, ['env', 'GOPATH'], (err, stdout, stderr) => {
if (err) {
Expand Down
11 changes: 10 additions & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,16 @@ export interface ICheckResult {
*/
export function runTool(args: string[], cwd: string, severity: string, useStdErr: boolean, toolName: string, env: any, printUnexpectedOutput: boolean, token?: vscode.CancellationToken): Promise<ICheckResult[]> {
let goRuntimePath = getGoRuntimePath();
let cmd = toolName ? getBinPath(toolName) : goRuntimePath;
let cmd;
if (toolName) {
cmd = getBinPath(toolName);
} else {
if (!goRuntimePath) {
return Promise.reject(new Error('Cannot find "go" binary. Update PATH or GOROOT appropriately'));
}
cmd = goRuntimePath;
}

let p: cp.ChildProcess;
if (token) {
token.onCancellationRequested(() => {
Expand Down