Skip to content

cmd/go: unclear error when path listed in go.work does not exist #55952

Closed
@adonovan

Description

@adonovan

@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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions