aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2015-01-16 22:15:01 -0500
committerRuss Cox <rsc@golang.org>2015-01-19 02:19:01 +0000
commite832043e7293cf3237e35ffc3b645c8d04d11f77 (patch)
treeb6b4bb8efe4c81255ab30397fd98ec4e18247a5e /src
parentdca54d7cdda3b88f5136c0ceee3eff99594e0643 (diff)
downloadgo-e832043e7293cf3237e35ffc3b645c8d04d11f77.tar.xz
cmd/go: set $GOROOT during 'go tool' invocations
cmd/dist now requires $GOROOT to be set explicitly. Set it when invoking via 'go tool dist' so that users are unaffected. Also, change go tool -n to drop trailing space in output for 'go tool -n <anything>'. Change-Id: I9b2c020e0a2f3fa7c9c339fadcc22cc5b6cb7cac Reviewed-on: https://go-review.googlesource.com/3011 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/go/tool.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/cmd/go/tool.go b/src/cmd/go/tool.go
index 3f11c3e3d4..dc8d34ba08 100644
--- a/src/cmd/go/tool.go
+++ b/src/cmd/go/tool.go
@@ -92,7 +92,11 @@ func runTool(cmd *Command, args []string) {
return
}
if toolN {
- fmt.Printf("%s %s\n", toolPath, strings.Join(args[1:], " "))
+ cmd := toolPath
+ if len(args) > 1 {
+ cmd += " " + strings.Join(args[1:], " ")
+ }
+ fmt.Printf("%s\n", cmd)
return
}
toolCmd := &exec.Cmd{
@@ -101,6 +105,8 @@ func runTool(cmd *Command, args []string) {
Stdin: os.Stdin,
Stdout: os.Stdout,
Stderr: os.Stderr,
+ // Set $GOROOT, mainly for go tool dist.
+ Env: mergeEnvLists([]string{"GOROOT=" + goroot}, os.Environ()),
}
err := toolCmd.Run()
if err != nil {