cmd/go: misleading error message for go mod download
in incorrect workspace
#54419
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
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?
I cloned an existing module, say
git.example.com/example/example-mod
, to my filesystem at~/work/example/example-mod
. It contains a valid go.mod file.GOPRIVATE
is configured as*.example.com
. I created a new workspace viago work init
in~/work/example
, but I forgot to add the module to it. Then, I rango mod download
inside the module.What did you expect to see?
Successfully downloaded dependencies, or an error message explaining that the current module is not in the workspace. Notably, I realized my problem because
go build
produced the latter:What did you see instead?
A confusing error message about the standard library with no indication of a problem with the workspace:
This was confusing because
all
, i.e.std cmd
, refers to valid modules in my Go installation, and the module in which I was running this command has a go.mod.The text was updated successfully, but these errors were encountered: