From f73f41df14cf0bb9658e7bd87463a81bdef84a50 Mon Sep 17 00:00:00 2001 From: Sam Herrmann Date: Sat, 12 Dec 2015 04:32:42 -0500 Subject: [PATCH] Ensure environment variables for gocode process are not configured for cross compilation --- src/goSuggest.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/goSuggest.ts b/src/goSuggest.ts index 2137a1d14..394b19b09 100644 --- a/src/goSuggest.ts +++ b/src/goSuggest.ts @@ -58,7 +58,15 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider { var gocode = getBinPath("gocode"); // Spawn `gocode` process - var p = cp.execFile(gocode, ["-f=json", "autocomplete", filename, "c" + offset], {}, (err, stdout, stderr) => { + var p = cp.execFile(gocode, ["-f=json", "autocomplete", filename, "c" + offset], { + env: { + // Unset GOOS and GOARCH for the `gocode` process to ensure that GOHOSTOS and GOHOSTARCH + // are used as the target operating system and architecture. `gocode` is unable to provide + // autocompletion when the Go environment is configured for cross compilation. + GOOS: "", + GOARCH: "" + } + }, (err, stdout, stderr) => { try { if (err && (err).code == "ENOENT") { vscode.window.showInformationMessage("The 'gocode' command is not available. Use 'go get -u github.com/nsf/gocode' to install.");