diff options
author | Bryan C. Mills <bcmills@google.com> | 2019-10-24 09:17:54 -0400 |
---|---|---|
committer | Bryan C. Mills <bcmills@google.com> | 2019-10-24 16:18:09 +0000 |
commit | fc3350686404a988e711aac84d70113660c882cf (patch) | |
tree | e402e344bc0e9a10435d4e749b6e831605c85768 /src/cmd/go/internal/modload/list.go | |
parent | b36f22bff04cf62f77d42d9584a050afffa2d723 (diff) | |
download | go-fc3350686404a988e711aac84d70113660c882cf.tar.gz go-fc3350686404a988e711aac84d70113660c882cf.zip |
cmd/go: re-enable 'go list -m' with -mod=vendor for limited patterns
I had prohibited 'go list -m' with -mod=vendor because the module
graph is incomplete, but I've realized that many queries do not
actually require the full graph — and may, in fact, be driven using
modules previously reported by 'go list' for specific, vendored
packages. Queries for those modules should succeed.
Updates #33848
Change-Id: I1000b4cf586a830bb78faf620ebf62d73a3cb300
Reviewed-on: https://go-review.googlesource.com/c/go/+/203138
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/list.go')
-rw-r--r-- | src/cmd/go/internal/modload/list.go | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/cmd/go/internal/modload/list.go b/src/cmd/go/internal/modload/list.go index 6c0b3945cb..cd162f8875 100644 --- a/src/cmd/go/internal/modload/list.go +++ b/src/cmd/go/internal/modload/list.go @@ -11,6 +11,7 @@ import ( "strings" "cmd/go/internal/base" + "cmd/go/internal/cfg" "cmd/go/internal/modinfo" "cmd/go/internal/module" "cmd/go/internal/par" @@ -124,10 +125,20 @@ func listModules(args []string, listVersions bool) []*modinfo.ModulePublic { } continue } - mods = append(mods, &modinfo.ModulePublic{ - Path: arg, - Error: modinfoError(arg, "", errors.New("not a known dependency")), - }) + if cfg.BuildMod == "vendor" { + // In vendor mode, we can't determine whether a missing module is “a + // known dependency” because the module graph is incomplete. + // Give a more explicit error message. + mods = append(mods, &modinfo.ModulePublic{ + Path: arg, + Error: modinfoError(arg, "", errors.New("can't resolve module using the vendor directory\n\t(Use -mod=mod or -mod=readonly to bypass.)")), + }) + } else { + mods = append(mods, &modinfo.ModulePublic{ + Path: arg, + Error: modinfoError(arg, "", errors.New("not a known dependency")), + }) + } } else { fmt.Fprintf(os.Stderr, "warning: pattern %q matched no module dependencies\n", arg) } |