]> Cypherpunks repositories - gostls13.git/commit
cmd/go: allow using go env with unknown vars already in go/env file
authorRuss Cox <rsc@golang.org>
Mon, 22 May 2023 18:05:08 +0000 (14:05 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 23 May 2023 02:43:14 +0000 (02:43 +0000)
commit88704b18ce9db36c04d788b688c42ef372ec2a5e
tree5d20a69e910d60700ad43f9b6a8a33c4f140d6a3
parent7f1467ff4ddd882acb318c0ffe24fd3702ce75cc
cmd/go: allow using go env with unknown vars already in go/env file

If you are using a newer toolchain and set go env -w X=Y, then it's
a bit frustrating that you can't update the variable in an older toolchain
with go env -w X=OTHER or go env -u X, or even see it with go env X.
This CL makes all those work.

This is particularly important when playing with go env -w GOTOOLCHAIN=oldversion
because from that point on the old version is handling 'go env' commands,
and the old version doesn't know about GOTOOLCHAIN.
The most complete way to recover from that situation is to use

GOTOOLCHAIN=local go env -w ...

but we will backport this CL to Go 1.19 and Go 1.20 so that they can
recover a bit more easily.

Fixes #59870.

Change-Id: I7a0bb043109e75a0d746069015f6e7992f78287f
Reviewed-on: https://go-review.googlesource.com/c/go/+/496957
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/cmd/go/internal/envcmd/env.go
src/cmd/go/testdata/script/env_write.txt