Skip to content

Commit

Permalink
src/goEnv: unset GOOS/GOARCH/GOROOT/... from tool installation env
Browse files Browse the repository at this point in the history
Tool installation is to build tools that would run in the host
machine. Applying GOOS/GOARCH/GOROOT/GOFLAGS/GOENV set to build
a cross-platform project is not the right choice.

Unset them and let the `go` command figure out.

There could be other environment variables that would affect
build (GCCGO, ..), and we will consider unsetting them.

Update #628

Change-Id: I295a0ae455aa2624550a16f69686bdf191fe41fd
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/264323
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
  • Loading branch information
hyangah committed Nov 19, 2020
1 parent d7563f6 commit bf1225f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/goEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ export function toolInstallationEnvironment(): NodeJS.Dict<string> {
}
env['GOPATH'] = toolsGopath;

// Unset env vars that would affect tool build process: 'GOROOT', 'GOOS', 'GOARCH', ...
// Tool installation should be done for the host OS/ARCH (GOHOSTOS/GOHOSTARCH) with
// the default setup.
delete env['GOOS'];
delete env['GOARCH'];
delete env['GOROOT'];
delete env['GOFLAGS'];
delete env['GOENV'];

return env;
}

Expand Down

0 comments on commit bf1225f

Please sign in to comment.