Closed
Description
@findleyr and I were briefly confused today by an error message from the Go command:
$ go build ./x
go: open /tmp/foo/y/go.mod: no such file or directory
Where did the name y come from? The answer turned out to be the go.work file, but it wasn't obvious. Here's the context:
$ pwd
/tmp/foo
$ cat go.work
use ./m
$ cat m/go.mod
module m
$ cat m/m.go
package m
$ go build ./m
$ mv m m2
$ go build ./m2
go: open /tmp/foo/m/go.mod: no such file or directory
Ideally the go command would emit an error more like this:
go: cannot load module m named in go.work file: open /tmp/foo/m/go.mod: no such file or directory