@@ -361,7 +361,7 @@ func build(ctx context.Context, ip string, dir string, platform v1.Platform, con
361361 cmd := exec .CommandContext (ctx , "go" , args ... )
362362 cmd .Dir = dir
363363
364- env , err := buildEnv (platform , config .Env )
364+ env , err := buildEnv (platform , os . Environ (), config .Env )
365365 if err != nil {
366366 return "" , fmt .Errorf ("could not create env for %s: %v" , ip , err )
367367 }
@@ -383,8 +383,9 @@ func build(ctx context.Context, ip string, dir string, platform v1.Platform, con
383383// buildEnv creates the environment variables used by the `go build` command.
384384// From `os/exec.Cmd`: If Env contains duplicate environment keys, only the last
385385// value in the slice for each duplicate key is used.
386- func buildEnv (platform v1.Platform , configEnv []string ) ([]string , error ) {
387- defaultEnv := []string {
386+ func buildEnv (platform v1.Platform , userEnv , configEnv []string ) ([]string , error ) {
387+ // Default env
388+ env := []string {
388389 "CGO_ENABLED=0" ,
389390 "GOOS=" + platform .OS ,
390391 "GOARCH=" + platform .Architecture ,
@@ -396,11 +397,11 @@ func buildEnv(platform v1.Platform, configEnv []string) ([]string, error) {
396397 return nil , fmt .Errorf ("goarm failure: %v" , err )
397398 }
398399 if goarm != "" {
399- defaultEnv = append (defaultEnv , "GOARM=" + goarm )
400+ env = append (env , "GOARM=" + goarm )
400401 }
401402 }
402403
403- env : = append (defaultEnv , os . Environ () ... )
404+ env = append (env , userEnv ... )
404405 env = append (env , configEnv ... )
405406 return env , nil
406407}
0 commit comments