make.go: pull cleanGoEnv out into a function

This commit is contained in:
Brad Fitzpatrick 2013-06-18 15:21:56 -07:00
parent cca2466547
commit 58b0d0fa02
1 changed files with 15 additions and 8 deletions

23
make.go
View File

@ -149,14 +149,10 @@ func main() {
args = append(args, "camlistore.org/cmd/cammount")
}
cmd := exec.Command("go", args...)
for _, env := range os.Environ() {
if strings.HasPrefix(env, "GOPATH=") || strings.HasPrefix(env, "GOBIN=") {
continue
}
cmd.Env = append(cmd.Env, env)
}
cmd.Env = append(cmd.Env, "GOPATH="+goPath)
cmd.Env = append(cmd.Env, "GOBIN="+binDir)
cmd.Env = append(cleanGoEnv(),
"GOPATH="+goPath,
"GOBIN="+binDir,
)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if *verbose {
@ -168,6 +164,17 @@ func main() {
log.Printf("Success. Binaries are in %s", binDir)
}
// cleanGoEnv returns a copy of the current environment with GOPATH and GOBIN removed.
func cleanGoEnv() (clean []string) {
for _, env := range os.Environ() {
if strings.HasPrefix(env, "GOPATH=") || strings.HasPrefix(env, "GOBIN=") {
continue
}
clean = append(clean, env)
}
return
}
// getVersion returns the version of Camlistore. Either from a VERSION file at the root,
// or from git.
func getVersion(camRoot string) string {