diff options
Diffstat (limited to 'libgo/go/cmd/go/internal/list/list.go')
-rw-r--r-- | libgo/go/cmd/go/internal/list/list.go | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/libgo/go/cmd/go/internal/list/list.go b/libgo/go/cmd/go/internal/list/list.go index a5f1abe64ae..b393c67ddb2 100644 --- a/libgo/go/cmd/go/internal/list/list.go +++ b/libgo/go/cmd/go/internal/list/list.go @@ -287,7 +287,7 @@ For more about modules, see 'go help modules'. func init() { CmdList.Run = runList // break init cycle - work.AddBuildFlags(CmdList) + work.AddBuildFlags(CmdList, work.DefaultBuildFlags) } var ( @@ -384,6 +384,22 @@ func runList(cmd *base.Command, args []string) { 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" { + 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.)") + } + } + } + modload.LoadBuildList() mods := modload.ListModules(args, *listU, *listVersions) |