1
0
mirror of https://github.com/golang/go synced 2024-11-24 04:30:14 -07:00

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 <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
This commit is contained in:
RenKanai 2022-03-27 22:06:22 +09:00 committed by Gopher Robot
parent 83907206de
commit 0ff91e03db
2 changed files with 7 additions and 0 deletions

View File

@ -925,6 +925,8 @@
// //
// The -find flag causes list to identify the named packages but not // The -find flag causes list to identify the named packages but not
// resolve their dependencies: the Imports and Deps lists will be empty. // 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 // The -test flag causes list to report not only the named packages
// but also their test binaries (for packages with tests), to convey to // but also their test binaries (for packages with tests), to convey to

View File

@ -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 The -find flag causes list to identify the named packages but not
resolve their dependencies: the Imports and Deps lists will be empty. 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 The -test flag causes list to report not only the named packages
but also their test binaries (for packages with tests), to convey to 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 { if *listFind && *listTest {
base.Fatalf("go list -test cannot be used with -find") 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{ pkgOpts := load.PackageOpts{
IgnoreImports: *listFind, IgnoreImports: *listFind,