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: better error for directory outside modules #56697

Closed
switchupcb opened this issue Nov 11, 2022 · 5 comments
Closed

cmd/go: better error for directory outside modules #56697

switchupcb opened this issue Nov 11, 2022 · 5 comments
Labels
FrozenDueToAge GoCommand cmd/go help wanted modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@switchupcb
Copy link

switchupcb commented Nov 11, 2022

directory . outside modules listed in go.work or their selected dependencies

It's not clear what's going on with this error due to the period alongside the lack of slashes indicating a file location. For this very specific situation, "directory ." could be replaced with "current directory" and save Google millions of engineer hours.

proposal: replace directory . outside modules listed in go.work or their selected dependencies with current directory is outside modules listed in go.work or their selected dependencies or directory ./ outside modules listed in go.work or their selected dependencies
proposal2: add go work toggle feature
proposal3: add way to exclude folder from go workspace

@gopherbot gopherbot added this to the Proposal milestone Nov 11, 2022
@switchupcb
Copy link
Author

This occurred when I attempted to use go build from ./_gen/ in this repository with the ./ in go.work removed. This happened because something (VSCODE?) set the GOWORK variable to the opened folder (./disgo), which toggles workspace mode (https://go.dev/ref/mod#workspaces). The fix was to set workspace mode off by setting the environment variable: GOWORK=off.

@switchupcb
Copy link
Author

Either I'm using workspaces incorrectly, or this is a good opportunity to suggest a toggle feature for the go work tool. Hopefully someone can show me that I'm wrong on the internet and how to fix that issue. Specifically, how to exclude directories from the workspace (cause I need to include ./ in go.work) and how to not have to use the GOWORK environment variable to build in that folder?

@switchupcb switchupcb changed the title proposal: workspace: add better language for go workspace error proposal: workspace: add toggle command Nov 11, 2022
@ianlancetaylor
Copy link
Contributor

CC @bcmills @matloob

Changing an error messages doesn't require a proposal, so taking this out of the proposal process. If you want to make one of the proposals you mention, I think it needs more explanation. Thanks.

@ianlancetaylor ianlancetaylor changed the title proposal: workspace: add toggle command cmd/go: better error for directory outside modules Nov 11, 2022
@ianlancetaylor ianlancetaylor added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed Proposal labels Nov 11, 2022
@ianlancetaylor ianlancetaylor modified the milestones: Proposal, Backlog Nov 11, 2022
@bcmills bcmills added GoCommand cmd/go modules NeedsFix The path to resolution is known, but the work has not been done. help wanted labels Nov 11, 2022
@gopherbot gopherbot removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 11, 2022
@switchupcb
Copy link
Author

switchupcb commented Nov 11, 2022

Here is my eventual end goal (use case) for that repository.

disgo.go (developers import this)
- `disgo` go module
- bundled code (fieldaligned)
- used in ./tools, ./cache, ./shard, ./_examples
- filepath is ./

wrapper (for development purposes only)
- `wrapper` go module
- human readable code
- not used anywhere
- filepath is ./wrapper

generator (used during development)
- not used as a go module (`go build`)
- generator code execution
- not used anywhere
- filepath is ./_gen

Currently, I can't do this because I must use ./ in the go workspace, but cannot exclude _,/gen or ./wrapper from the go.work file.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/451295 mentions this issue: cmd/go: replace 'directory .' with 'current directory' in some errors

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

No branches or pull requests

4 participants