-
Notifications
You must be signed in to change notification settings - Fork 17.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/go: mention go.work when local path outside modules in go.work
In workspace mode, if a user lists a package or patternthat's inside a module that's not listed in go.work, mention that the package or pattern is outside the modules listed in go.work so the user has a better idea of how to fix the issue. (Question: it's valid in those flows to add a pattern that points into the module cache. Should we expand the error to say "package outside modules listed in go.work file or contained in module cache"? That seems clunky (and is the uncommon case) which is why I didn't do so in this case, but it's possible) Fixes #49632 Change-Id: I3f0ea1b2f566d52a8079b58593fcc5cc095e7a41 Reviewed-on: https://go-review.googlesource.com/c/go/+/384236 Trust: Michael Matloob <matloob@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
- Loading branch information
Showing
6 changed files
with
46 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# This is a regression test for issue #49632. | ||
# The Go command should mention go.work if the user | ||
# tries to load a local package that's in a module | ||
# that's not in go.work and can't be resolved. | ||
|
||
! go list ./... | ||
stderr 'pattern ./...: directory prefix . does not contain modules listed in go.work or their selected dependencies' | ||
|
||
! go list ./a | ||
stderr 'directory a outside modules listed in go.work' | ||
|
||
-- go.work -- | ||
go 1.18 | ||
|
||
use ./b | ||
-- a/go.mod -- | ||
module example.com/a | ||
|
||
go 1.18 | ||
-- a/a.go -- | ||
package a | ||
-- b/go.mod -- | ||
module example.com/b | ||
|
||
go 1.18 |