File tree 2 files changed +17
-2
lines changed
2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -390,15 +390,24 @@ func runList(cmd *base.Command, args []string) {
390
390
391
391
modload .InitMod () // Parses go.mod and sets cfg.BuildMod.
392
392
if cfg .BuildMod == "vendor" {
393
+ const actionDisabledFormat = "go list -m: can't %s using the vendor directory\n \t (Use -mod=mod or -mod=readonly to bypass.)"
394
+
395
+ if * listVersions {
396
+ base .Fatalf (actionDisabledFormat , "determine available versions" )
397
+ }
398
+ if * listU {
399
+ base .Fatalf (actionDisabledFormat , "determine available upgrades" )
400
+ }
401
+
393
402
for _ , arg := range args {
394
403
// In vendor mode, the module graph is incomplete: it contains only the
395
404
// explicit module dependencies and the modules that supply packages in
396
405
// the import graph. Reject queries that imply more information than that.
397
406
if arg == "all" {
398
- base .Fatalf ("go list -m: can't compute 'all' using the vendor directory \n \t (Use -mod=mod or -mod=readonly to bypass.) " )
407
+ base .Fatalf (actionDisabledFormat , " compute 'all'" )
399
408
}
400
409
if strings .Contains (arg , "..." ) {
401
- base .Fatalf ("go list -m: can't match module patterns using the vendor directory \n \t (Use -mod=mod or -mod=readonly to bypass.) " )
410
+ base .Fatalf (actionDisabledFormat , " match module patterns" )
402
411
}
403
412
}
404
413
}
Original file line number Diff line number Diff line change @@ -38,6 +38,12 @@ stdout 'src[\\/]vendor[\\/]x'
38
38
go list -mod=vendor -f '{{.Version}} {{.Dir}}' -m x
39
39
stdout '^v1.0.0 $'
40
40
41
+ # -mod=vendor should cause 'go list' flags that look up versions to fail.
42
+ ! go list -mod=vendor -versions -m x
43
+ stderr '^go list -m: can''t determine available versions using the vendor directory\n\t\(Use -mod=mod or -mod=readonly to bypass.\)$'
44
+ ! go list -mod=vendor -u -m x
45
+ stderr '^go list -m: can''t determine available upgrades using the vendor directory\n\t\(Use -mod=mod or -mod=readonly to bypass.\)$'
46
+
41
47
# 'go list -mod=vendor -m' on a transitive dependency that does not
42
48
# provide vendored packages should give a helpful error rather than
43
49
# 'not a known dependency'.
You can’t perform that action at this time.
0 commit comments