diff options
author | Philipp Sauter <sauterp@protonmail.com> | 2020-11-08 22:12:38 +0100 |
---|---|---|
committer | Bryan C. Mills <bcmills@google.com> | 2021-05-05 01:28:34 +0000 |
commit | 4df662fb373480b5055e645120558bb536fae42c (patch) | |
tree | 56e29e105f1f96e348060959b03ab4d49ea959b0 /src/cmd/go/internal/envcmd/env.go | |
parent | bb5e45219af69135c389c6b68f9a67207bb32e05 (diff) | |
download | go-4df662fb373480b5055e645120558bb536fae42c.tar.gz go-4df662fb373480b5055e645120558bb536fae42c.zip |
cmd/go: don't crash when running "go version" in deleted directory
If the go command is executed on Linux in a deleted directory,
it fails. This behavior is reasonable for commands which depend on
the CWD, but it's unexpected for commands like `go version`.
This change delays initialization of a global CWD variable.
Fixed #34499
Change-Id: I7302fb84a3b7f5f149a123d277abd5b9b5bc95b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/268261
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Diffstat (limited to 'src/cmd/go/internal/envcmd/env.go')
-rw-r--r-- | src/cmd/go/internal/envcmd/env.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/cmd/go/internal/envcmd/env.go b/src/cmd/go/internal/envcmd/env.go index 8dbb8af1e7..b30c37ab27 100644 --- a/src/cmd/go/internal/envcmd/env.go +++ b/src/cmd/go/internal/envcmd/env.go @@ -200,7 +200,7 @@ func runEnv(ctx context.Context, cmd *base.Command, args []string) { env := cfg.CmdEnv env = append(env, ExtraEnvVars()...) - if err := fsys.Init(base.Cwd); err != nil { + if err := fsys.Init(base.Cwd()); err != nil { base.Fatalf("go: %v", err) } |