-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: document that empty environment variables are treated as unset #50335
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
how can i unset goprivate |
You can use The Go environment variables are intended to be structured such that there is always some valid non-empty string you can use to get the default behavior. For |
in local terminal,i see : set GOPRIVATE=five.com/library.git set GOENV=C:\Users\001\AppData\Roaming\go\env 2.go env -w GOPRIVATE=none warning: go env -w GOPRIVATE=... does not override conflicting OS environment variable watch in GOENV=C:\Users\001\AppData\Roaming\go\env GO111MODULE=auto GOPRIVATE=none GOPROXY=https://goproxy.cn go env found: set GOPRIVATE=five.com/library.git
GO111MODULE=auto GOPROXY=https://goproxy.cnwatch env goprivate disappears,but go env found: set GOPRIVATE=five.com/library.gitit still exist. |
Dear bcmills,I slove it.In my OS Envrionment,i see it,and then delete it.It succeses! |
The current behavior of treating the empty string in the process environment as equivalent to unset is intentional. And from what I can tell the behavior you are seeing with However, looking at https://pkg.go.dev/cmd/go#hdr-Environment_variables, I see:
That sentence should be updated to say “unset or empty” instead of “unset”. |
thank you somuch,it works
Bryan C. Mills ***@***.***> 于2022年4月13日周三 01:54写道:
… The current behavior of treating the empty string in the process
environment as equivalent to unset is intentional.
And from what I can tell the behavior you are seeing with go env -w and
set is consistent with that: if you set the variable to a non-empty value
in both the GOENV file and the process environment, the environment wins;
if you set it in the GOENV file but not the process environment, then the
value from the GOENV file is used.
However, looking at https://pkg.go.dev/cmd/go#hdr-Environment_variables,
I see:
If an environment variable is unset, the go command uses a sensible
default setting.
That sentence should be updated to say “unset or empty” instead of “unset”.
—
Reply to this email directly, view it on GitHub
<#50335 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AWFQFB2QXA7JQ53IMGMNLY3VEW2FLANCNFSM5KWMIXXA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Change https://go.dev/cl/475695 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?
What did you expect to see?
Expect
go env GOPRIVATE
print nothing. BecauseGOPRIVATE
is exist, and its value is empty.an environment variable is set with empty value
vsan environment variable is not exist
an environment variable is not exist
.an environment variable is set with empty value
.What did you see instead?
go env GOPRIVATE
printbbb
.Suggestion
Relative code: https://github.com/golang/go/blob/go1.17.5/src/cmd/go/internal/cfg/cfg.go#L239-L242
Should be:
The text was updated successfully, but these errors were encountered: