cmd/go: go generate sets more variables than its documentation specifies #41943
Labels
GoCommand
cmd/go
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone
go generate
documentation currently says:The last sentence is relevant. It leads the user to believe that if a NAME is not one of the aforementioned variables and is not set in the environment, $NAME would expand to the empty string.
This is not the case for some Go-specific variables (beyond those mentioned in the list above) because
expandVar
usesos.Getenv(word)
to look up environment variables that aren't ing.env
. To achieve the behavior as documented above, it should instead be looking up environment variables fromcfg.OrigEnv
, since cmd/go'smain
modifies the environment at startup (see here).To reproduce, consider this program:
What did you do?
What did you expect to see?
What did you see instead?
/cc @bcmills @jayconrod @matloob
The text was updated successfully, but these errors were encountered: