cmd/go: document that go env GOMOD can return /dev/null #36052
Labels
Documentation
Issues describing a change to documentation.
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
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?
The docs for
GOMOD
state:For some time I have (incorrectly) been advising people that the way to determine if you are in a module context or not (i.e. modules not off and you are in the context of a
go.mod
) is by testing whether the output fromgo env GOMOD
is the empty string or not.However this fails when you consider:
It's also not clear the docs are quite correct when it comes to modules being not off (i.e. auto or on):
(i.e. empty string, but we aren't not using modules, we are in the auto mode. Granted this is a bit less clearly incorrect)
I realise that this way
go env GOMOD
can be used to determine whether modules are off/not off, and whether you are in a module context or not assuming that they are not off. But documenting this a bit more clearly would, I think, help (selfishly me at least).Because the actual logic for correctly determining that modules are not off and you are in a module context is:
Thoughts?
cc @bcmills @jayconrod
FYI @mvdan @kortschak
The text was updated successfully, but these errors were encountered: