src/goEnv: unset GOOS/GOARCH/GOROOT/... from tool installation env
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 golang/vscode-go#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>
diff --git a/src/goEnv.ts b/src/goEnv.ts
index 556686a..754ff52 100644
--- a/src/goEnv.ts
+++ b/src/goEnv.ts
@@ -39,6 +39,15 @@
}
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;
}