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 via go work init in ~/work/example, but I forgot to add the module to it. Then, I ran go 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:
~/work/example/example-mod$ go build
go: no modules were found in the current workspace; see 'go help work'
What did you see instead?
A confusing error message about the standard library with no indication of a problem with the workspace:
~/work/example/example-mod$ go mod download
go: cannot match "all": go.mod file not found in current directory or any parent directory; see 'go help modules'
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: