Skip to content
This repository has been archived by the owner on Feb 7, 2022. It is now read-only.

add goproxy env #193

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions xgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ func pullDockerImage(image string) error {
return run(exec.Command("docker", "pull", image))
}

var goEnv = []string{"GOPROXY", "GOPRIVATE", "GOSUMDB", "GOMIPS"}

// compile cross builds a requested package according to the given build specs
// using a specific docker cross compilation image.
func compile(image string, config *ConfigFlags, flags *BuildFlags, folder string) error {
Expand Down Expand Up @@ -299,12 +301,17 @@ func compile(image string, config *ConfigFlags, flags *BuildFlags, folder string
"-e", fmt.Sprintf("FLAG_BUILDMODE=%s", flags.Mode),
"-e", "TARGETS=" + strings.Replace(strings.Join(config.Targets, " "), "*", ".", -1),
}
for _, key := range goEnv {
if e := os.Getenv(key); len(e) > 0 {
args = append(args, "-e", fmt.Sprintf("%s=%s", key, e))
}
}
for i := 0; i < len(locals); i++ {
args = append(args, []string{"-v", fmt.Sprintf("%s:%s:ro", locals[i], mounts[i])}...)
args = append(args, "-v", fmt.Sprintf("%s:%s:ro", locals[i], mounts[i]))
}
args = append(args, []string{"-e", "EXT_GOPATH=" + strings.Join(paths, ":")}...)
args = append(args, "-e", "EXT_GOPATH="+strings.Join(paths, ":"))

args = append(args, []string{image, config.Repository}...)
args = append(args, image, config.Repository)
return run(exec.Command("docker", args...))
}

Expand Down Expand Up @@ -334,6 +341,11 @@ func compileContained(config *ConfigFlags, flags *BuildFlags, folder string) err
fmt.Sprintf("FLAG_BUILDMODE=%s", flags.Mode),
"TARGETS=" + strings.Replace(strings.Join(config.Targets, " "), "*", ".", -1),
}
for _, key := range goEnv {
if e := os.Getenv(key); len(e) > 0 {
env = append(env, "-e", fmt.Sprintf("%s=%s", key, e))
}
}
if local {
env = append(env, "EXT_GOPATH=/non-existent-path-to-signal-local-build")
}
Expand Down