Skip to content
This repository was archived by the owner on Sep 24, 2021. It is now read-only.

Commit 554c7ac

Browse files
JanKoehnleinramya-rao-a
authored andcommitted
Fail with better error messages if go binary cannot be found (microsoft#1543)
#17 Signed-off-by: Jan Koehnlein <jan.koehnlein@typefox.io>
1 parent 1db698f commit 554c7ac

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/goInstallTools.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,9 @@ export function updateGoPathGoRootFromConfig(): Promise<void> {
292292

293293
// If GOPATH is still not set, then use the one from `go env`
294294
let goRuntimePath = getGoRuntimePath();
295+
if (!goRuntimePath) {
296+
return Promise.reject(new Error('Cannot find "go" binary. Update PATH or GOROOT appropriately'));
297+
}
295298
return new Promise<void>((resolve, reject) => {
296299
cp.execFile(goRuntimePath, ['env', 'GOPATH'], (err, stdout, stderr) => {
297300
if (err) {

src/util.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,16 @@ export interface ICheckResult {
562562
*/
563563
export function runTool(args: string[], cwd: string, severity: string, useStdErr: boolean, toolName: string, env: any, printUnexpectedOutput: boolean, token?: vscode.CancellationToken): Promise<ICheckResult[]> {
564564
let goRuntimePath = getGoRuntimePath();
565-
let cmd = toolName ? getBinPath(toolName) : goRuntimePath;
565+
let cmd;
566+
if (toolName) {
567+
cmd = getBinPath(toolName);
568+
} else {
569+
if (!goRuntimePath) {
570+
return Promise.reject(new Error('Cannot find "go" binary. Update PATH or GOROOT appropriately'));
571+
}
572+
cmd = goRuntimePath;
573+
}
574+
566575
let p: cp.ChildProcess;
567576
if (token) {
568577
token.onCancellationRequested(() => {

0 commit comments

Comments
 (0)