mirror of
https://github.com/golang/go
synced 2024-11-23 00:40:08 -07:00
cmd/go: emit error when listing with -f and -json
Fixes #44738 Change-Id: Ie57ddcbe87408c9644313ec2a9ea347b4d6de76b Reviewed-on: https://go-review.googlesource.com/c/go/+/298029 Reviewed-by: Bryan C. Mills <bcmills@google.com> Trust: Jay Conrod <jayconrod@google.com>
This commit is contained in:
parent
402d784b8f
commit
9f4d5c94b0
@ -335,6 +335,10 @@ var (
|
||||
var nl = []byte{'\n'}
|
||||
|
||||
func runList(ctx context.Context, cmd *base.Command, args []string) {
|
||||
if *listFmt != "" && *listJson == true {
|
||||
base.Fatalf("go list -f cannot be used with -json")
|
||||
}
|
||||
|
||||
load.ModResolveTests = *listTest
|
||||
work.BuildInit()
|
||||
out := newTrackingWriter(os.Stdout)
|
||||
|
20
src/cmd/go/testdata/script/list_json_with_f.txt
vendored
Normal file
20
src/cmd/go/testdata/script/list_json_with_f.txt
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
[short] skip
|
||||
|
||||
# list -json should generate output on stdout
|
||||
go list -json ./...
|
||||
stdout .
|
||||
# list -f should generate output on stdout
|
||||
go list -f '{{.}}' ./...
|
||||
stdout .
|
||||
|
||||
# test passing first -json then -f
|
||||
! go list -json -f '{{.}}' ./...
|
||||
stderr '^go list -f cannot be used with -json$'
|
||||
|
||||
# test passing first -f then -json
|
||||
! go list -f '{{.}}' -json ./...
|
||||
stderr '^go list -f cannot be used with -json$'
|
||||
-- go.mod --
|
||||
module m
|
||||
-- list_test.go --
|
||||
package list_test
|
Loading…
Reference in New Issue
Block a user