Skip to content
This repository was archived by the owner on Aug 14, 2020. It is now read-only.

Commit 22a59ad

Browse files
committed
Forward GOROOT env var to go get
Most users of prebuilt go have to specify GOROOT env var themselves - prebuilt go insists on having GOROOT in, for example, /usr/local/go.
1 parent 556c8e2 commit 22a59ad

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

goaci.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@ func main() {
6868
flag.StringVar(&goPathOpt, "go-path", "", "Custom GOPATH (default: a temporary directory)")
6969
flag.Parse()
7070
if os.Getenv("GOPATH") != "" {
71-
warn("GOPATH envvar is ignored, use --go-path=\"$GOPATH\" option instead")
71+
warn("GOPATH env var is ignored, use --go-path=\"$GOPATH\" option instead")
7272
}
73-
if os.Getenv("GOROOT") != "" {
74-
warn("GOROOT envvar is ignored, use --go-binary=\"$GOROOT/bin/go\" option instead")
73+
goRoot := os.Getenv("GOROOT")
74+
if goRoot != "" {
75+
warn("Overriding GOROOT env var to %s", goRoot)
7576
}
7677
if os.Getenv("GOACI_DEBUG") != "" {
7778
Debug = true
@@ -131,13 +132,17 @@ func main() {
131132
die("error opening output file: %v", err)
132133
}
133134

135+
env := []string{
136+
"GOPATH=" + goPathOpt,
137+
"GOBIN=" + gobin,
138+
"CGO_ENABLED=0",
139+
"PATH=" + os.Getenv("PATH"),
140+
}
141+
if goRoot != "" {
142+
env = append(env, "GOROOT="+goRoot)
143+
}
134144
cmd := exec.Cmd{
135-
Env: []string{
136-
"GOPATH=" + goPathOpt,
137-
"GOBIN=" + gobin,
138-
"CGO_ENABLED=0",
139-
"PATH=" + os.Getenv("PATH"),
140-
},
145+
Env: env,
141146
Path: goBinaryOpt,
142147
Args: args,
143148
Stderr: os.Stderr,

0 commit comments

Comments
 (0)