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>
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)
--- /dev/null
+[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