aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/list/list.go
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2019-10-24 09:17:54 -0400
committerBryan C. Mills <bcmills@google.com>2019-10-24 16:18:09 +0000
commitfc3350686404a988e711aac84d70113660c882cf (patch)
treee402e344bc0e9a10435d4e749b6e831605c85768 /src/cmd/go/internal/list/list.go
parentb36f22bff04cf62f77d42d9584a050afffa2d723 (diff)
downloadgo-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/list/list.go')
-rw-r--r--src/cmd/go/internal/list/list.go15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/cmd/go/internal/list/list.go b/src/cmd/go/internal/list/list.go
index 7965a84f99..b393c67ddb 100644
--- a/src/cmd/go/internal/list/list.go
+++ b/src/cmd/go/internal/list/list.go
@@ -381,17 +381,22 @@ func runList(cmd *base.Command, args []string) {
base.Fatalf("go list -test cannot be used with -m")
}
- buildModIsDefault := (cfg.BuildMod == "")
if modload.Init(); !modload.Enabled() {
base.Fatalf("go list -m: not using modules")
}
modload.InitMod() // Parses go.mod and sets cfg.BuildMod.
if cfg.BuildMod == "vendor" {
- if buildModIsDefault {
- base.Fatalf("go list -m: can't list modules using the vendor directory\n\tUse -mod=mod or -mod=readonly to ignore it.")
- } else {
- base.Fatalf("go list -m: can't list modules with -mod=vendor\n\tUse -mod=mod or -mod=readonly to ignore the vendor directory.")
+ for _, arg := range args {
+ // In vendor mode, the module graph is incomplete: it contains only the
+ // explicit module dependencies and the modules that supply packages in
+ // the import graph. Reject queries that imply more information than that.
+ if arg == "all" {
+ base.Fatalf("go list -m: can't compute 'all' using the vendor directory\n\t(Use -mod=mod or -mod=readonly to bypass.)")
+ }
+ if strings.Contains(arg, "...") {
+ base.Fatalf("go list -m: can't match module patterns using the vendor directory\n\t(Use -mod=mod or -mod=readonly to bypass.)")
+ }
}
}