From 58b0d0fa02ac2a40de6f684eef2f841ed40b4843 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 18 Jun 2013 15:21:56 -0700 Subject: [PATCH] make.go: pull cleanGoEnv out into a function --- make.go | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/make.go b/make.go index dcab8abb0..7b70f63bf 100644 --- a/make.go +++ b/make.go @@ -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 {