Skip to content

Commit f3c86ba

Browse files
committed
cmd/go: update PWD variable for 'go generate'
Most subprocess invocations in the go command use base.AppendPWD to append an accurate value of PWD to the command's environment, which can speed up calls like os.Getwd and also help to provide less-confusing output from scripts. Update `go generate` to do so. Fixes golang#43862 Change-Id: I3b756f1532b2d922f7d74fd86414d5567a0122c0
1 parent a61524d commit f3c86ba

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/cmd/go/internal/generate/generate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ func (g *Generator) exec(words []string) {
448448
cmd.Stderr = os.Stderr
449449
// Run the command in the package directory.
450450
cmd.Dir = g.dir
451-
cmd.Env = str.StringList(cfg.OrigEnv, g.env)
451+
cmd.Env = base.AppendPWD(str.StringList(cfg.OrigEnv, g.env), cmd.Dir)
452452
err := cmd.Run()
453453
if err != nil {
454454
g.errorf("running %q: %s", words[0], err)

0 commit comments

Comments
 (0)