diff options
author | Bryan C. Mills <bcmills@google.com> | 2019-11-03 20:53:47 -0500 |
---|---|---|
committer | Bryan C. Mills <bcmills@google.com> | 2019-11-05 18:03:54 +0000 |
commit | a9c0cc6f6744654de7f8fdff52f5da601a109d11 (patch) | |
tree | e3518272aa373211070d0089815cb05fd622a0b1 /src/cmd/go/internal/modload/load.go | |
parent | 95149147d86ad33a82a5d0115bbb9c623cd7cade (diff) | |
download | go-a9c0cc6f6744654de7f8fdff52f5da601a109d11.tar.gz go-a9c0cc6f6744654de7f8fdff52f5da601a109d11.zip |
cmd/go: make 'go mod why' require a main module
Updates #32027
Change-Id: Ifc9427f35188c3fd356917d8510f3e01866ebca8
Reviewed-on: https://go-review.googlesource.com/c/go/+/205065
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Diffstat (limited to 'src/cmd/go/internal/modload/load.go')
-rw-r--r-- | src/cmd/go/internal/modload/load.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/cmd/go/internal/modload/load.go b/src/cmd/go/internal/modload/load.go index acb968cdfa..2172f81797 100644 --- a/src/cmd/go/internal/modload/load.go +++ b/src/cmd/go/internal/modload/load.go @@ -406,6 +406,10 @@ func loadAll(testAll bool) []string { // matching pattern, which may be relative to the working directory, under all // build tag settings. func TargetPackages(pattern string) []string { + // TargetPackages is relative to the main module, so ensure that the main + // module is a thing that can contain packages. + ModRoot() + return matchPackages(pattern, imports.AnyTags(), false, []module.Version{Target}) } |