Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: improve error message when working in a module that's outside of go.work #49632

Closed
hyangah opened this issue Nov 17, 2021 · 5 comments
Closed
Labels
FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@hyangah
Copy link
Contributor

hyangah commented Nov 17, 2021

$ go version
go version devel go1.18-3d7cb23e3d Wed Nov 17 01:56:19 2021 +0000 darwin/amd64

When running a go command in a directory whose parent directory defines go.work but does not include this directory in its use section, the go command output is rather confusing.

$ ls
delve
go.work
tools
$ cat go.work
go 1.18

use delve
$ cd tools; go list ./...
pattern ./...: directory prefix . outside available modules

Even though users can check go env GOWORK, consider to explicitly mention the existence of go.work.
(maybe something like pattern ./...: directory prefix . outside modules listed in go.work?)

Or, let it operate in a single module mode as if there is no go.work - but not sure which one is less confusing.

@bcmills
Copy link
Member

bcmills commented Nov 17, 2021

CC @matloob

@bcmills bcmills added modules NeedsFix The path to resolution is known, but the work has not been done. labels Nov 17, 2021
@bcmills bcmills added this to the Go1.18 milestone Nov 17, 2021
@matloob matloob self-assigned this Nov 22, 2021
@ianlancetaylor
Copy link
Contributor

@matloob This is in the 1.18 milestone; time to move to 1.19? Thanks.

@matloob
Copy link
Contributor

matloob commented Feb 3, 2022

I can fix this for 1.18.

@gopherbot
Copy link

Change https://go.dev/cl/384236 mentions this issue: cmd/go: mention go.work when local path outside modules in go.work

@perillo
Copy link
Contributor

perillo commented Feb 9, 2022

What is the reason why the main module is not automatically included in the workspace?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

6 participants