-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: env -w can set (but not remove) an invalid GOOS and GOARCH value #34194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Certainly CC @jayconrod |
Pushing things a bit, proper checking in
Basically, the If you decide to go into the check when change option, looking again |
Change https://golang.org/cl/194617 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Write config file regarding
GOOS
with a typo:~ % go env -w GOOS=linuxx
What did you expect to see?
Some error indicating the value being incorrect.
What did you see instead?
Command ran successfully and written to config file, then doing
go env
will result in an error:Despite this mean setting an invalid GOOS value, it can't be fixed with
-w
again:So basically I had to edit
$GOENV
file manually to get unstuck.The error output is the result of calling
MkEnv()
inmain.go
which eventually detects the invalid value and exits. This means that any-w
attempt to fix the invalid value won't be reached to make it.An option can be to do the same control setting a valid value with
-w
to avoid being invalid.A similar thing happens if an invalid value is set with
export GOOS=linuxx
, but that's somehow OK since external envGOOS
set isn't ingo
command control.Similarly, the same situation happens with an invalid
env -w GOARCH
.If checking these situations in
env -w
makes sense, I can make a PR adding this validation incheckEnvWrite()
which I think would the correct place: one extracase "GOOS", "GOARCH":
.Some tests can also be added to cover this.
The text was updated successfully, but these errors were encountered: