]> Cypherpunks repositories - gostls13.git/commitdiff
go/build: replace a call to os.Environ with (*exec.Cmd).Environ
authorBryan C. Mills <bcmills@google.com>
Thu, 21 Apr 2022 15:19:56 +0000 (11:19 -0400)
committerBryan Mills <bcmills@google.com>
Thu, 21 Apr 2022 17:49:00 +0000 (17:49 +0000)
This is a code simplification using the new API added in #50599.

Change-Id: Icb9628bcd0daa3dc2d653e9654b38099730137d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/401535
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/go/build/build.go

index 17fef051b3f72ba62ba3d7f719ffa67bbbdfe2bb..bfa9cd60fb1840403669a61464e4d74a4d5a5b81 100644 (file)
@@ -1185,20 +1185,13 @@ func (ctxt *Context) importGo(p *Package, path, srcDir string, mode ImportMode)
        if ctxt.CgoEnabled {
                cgo = "1"
        }
-       cmd.Env = append(os.Environ(),
+       cmd.Env = append(cmd.Environ(),
                "GOOS="+ctxt.GOOS,
                "GOARCH="+ctxt.GOARCH,
                "GOROOT="+ctxt.GOROOT,
                "GOPATH="+ctxt.GOPATH,
                "CGO_ENABLED="+cgo,
        )
-       if cmd.Dir != "" {
-               // If possible, set PWD: if an error occurs and PWD includes a symlink, we
-               // want the error to refer to Dir, not some other name for it.
-               if abs, err := filepath.Abs(cmd.Dir); err == nil {
-                       cmd.Env = append(cmd.Env, "PWD="+abs)
-               }
-       }
 
        if err := cmd.Run(); err != nil {
                return fmt.Errorf("go/build: go list %s: %v\n%s\n", path, err, stderr.String())