From: RenKanai Date: Sun, 27 Mar 2022 13:06:22 +0000 (+0900) Subject: cmd/go: reject list when -find and -export are used together X-Git-Tag: go1.21rc1~1449 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=0ff91e03dbb7ed169915b12793cbee9ca9798d4c;p=gostls13.git cmd/go: reject list when -find and -export are used together Fixes #51952. Change-Id: If2cfc41d65373ca38cfb7b0396be8988d444eb5e Reviewed-on: https://go-review.googlesource.com/c/go/+/396074 Run-TryBot: Bryan Mills TryBot-Result: Gopher Robot Reviewed-by: David Chase Reviewed-by: Bryan Mills Auto-Submit: Bryan Mills Reviewed-by: Dmitri Shuralyov --- diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go index 6b91b53347..0f8433efca 100644 --- a/src/cmd/go/alldocs.go +++ b/src/cmd/go/alldocs.go @@ -925,6 +925,8 @@ // // The -find flag causes list to identify the named packages but not // resolve their dependencies: the Imports and Deps lists will be empty. +// With the -find flag, the -deps, -test and -export commands cannot be +// used. // // The -test flag causes list to report not only the named packages // but also their test binaries (for packages with tests), to convey to diff --git a/src/cmd/go/internal/list/list.go b/src/cmd/go/internal/list/list.go index 7f3090872b..259fa2c857 100644 --- a/src/cmd/go/internal/list/list.go +++ b/src/cmd/go/internal/list/list.go @@ -193,6 +193,8 @@ and the BuildID field to the build ID of the compiled package. The -find flag causes list to identify the named packages but not resolve their dependencies: the Imports and Deps lists will be empty. +With the -find flag, the -deps, -test and -export commands cannot be +used. The -test flag causes list to report not only the named packages but also their test binaries (for packages with tests), to convey to @@ -592,6 +594,9 @@ func runList(ctx context.Context, cmd *base.Command, args []string) { if *listFind && *listTest { base.Fatalf("go list -test cannot be used with -find") } + if *listFind && *listExport { + base.Fatalf("go list -export cannot be used with -find") + } pkgOpts := load.PackageOpts{ IgnoreImports: *listFind,