Provide args to BuildWithEnv as slice not map
diff --git a/gexec/build.go b/gexec/build.go
index 462f033..d11b2fd 100644
--- a/gexec/build.go
+++ b/gexec/build.go
@@ -30,7 +30,7 @@
/*
BuildWithEnvironment is identical to Build but allows you to specify env vars to be set at build time.
*/
-func BuildWithEnvironment(packagePath string, env map[string]string, args ...string) (compiledPath string, err error) {
+func BuildWithEnvironment(packagePath string, env []string, args ...string) (compiledPath string, err error) {
return doBuild(os.Getenv("GOPATH"), packagePath, env, args...)
}
@@ -41,7 +41,7 @@
return doBuild(gopath, packagePath, nil, args...)
}
-func doBuild(gopath, packagePath string, env map[string]string, args ...string) (compiledPath string, err error) {
+func doBuild(gopath, packagePath string, env []string, args ...string) (compiledPath string, err error) {
tmpDir, err := temporaryDirectory()
if err != nil {
return "", err
@@ -61,11 +61,7 @@
build := exec.Command("go", cmdArgs...)
build.Env = append([]string{"GOPATH=" + gopath}, os.Environ()...)
-
- for k, v := range env {
- envVar := k + "=" + v
- build.Env = append(build.Env, envVar)
- }
+ build.Env = append(build.Env, env...)
output, err := build.CombinedOutput()
if err != nil {
diff --git a/gexec/build_test.go b/gexec/build_test.go
index c090339..8df0790 100644
--- a/gexec/build_test.go
+++ b/gexec/build_test.go
@@ -40,9 +40,9 @@
var _ = Describe(".BuildWithEnvironment", func() {
var err error
- env := map[string]string{
- "GOOS": "linux",
- "GOARCH": "amd64",
+ env := []string{
+ "GOOS=linux",
+ "GOARCH=amd64",
}
It("compiles the specified package with the specified env vars", func() {