-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: workspace detected outside of workspace #51604
Comments
you still need go.mod, though you have go.work |
How about if |
Change https://go.dev/cl/400014 mentions this issue: |
Looks like this fix was incomplete:
|
(And the |
Change https://go.dev/cl/418094 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
At least current gotip.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I created a workspace using
go work init
a level below an existing module and then tried to run my existing module.e.g. with:
Inside of
foo
I ran:What did you expect to see? / What did you see instead?
Since my module isn't a part of the workspace I expect it to run/build.
The error messages for
build
andrun
do point me in the right direction, but if I instead have a slightly different scenario where I just forget (or don't know that I should) addfoo
to mygo.work
file:Then gopls actually works as expected (can dereference
a.A
inmain.go
etc), but building/running fails with a more confusing error message:Again I would expect it to not use workspace mode since the module itself isn't a part of the workspace (or drop an error and refuse to build/run).
The benefits of not using workspace mode in this case would be that the tooling (e.g. gopls) wouldn't resolve the packages so it gets obvious to the user that something is wrong.
On the other side, if the workspace for example replace a version, things gets more subtle and that speaks in favor of erroring out.
The text was updated successfully, but these errors were encountered: