1
0
mirror of https://github.com/golang/go synced 2024-11-19 09:54:49 -07:00

cmd/go: force default env vars onto tool subprocesses

This avoids needing every invoked tool to have an identical
computation of the build defaults as the go command does.
It makes sure the tools all know what the go command wants.

Change-Id: I484f15982bfb93c86cde8fc9df7f456505270b87
Reviewed-on: https://go-review.googlesource.com/6409
Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
Russ Cox 2015-03-01 20:03:49 -05:00
parent deff22dd88
commit b38fa898c6

View File

@ -152,6 +152,15 @@ func main() {
os.Exit(2)
}
// Set environment (GOOS, GOARCH, etc) explicitly.
// In theory all the commands we invoke should have
// the same default computation of these as we do,
// but in practice there might be skew
// This makes sure we all agree.
for _, env := range mkEnv() {
os.Setenv(env.name, env.value)
}
for _, cmd := range commands {
if cmd.Name() == args[0] && cmd.Runnable() {
cmd.Flag.Usage = func() { cmd.Usage() }