From 7dbbeea110b8e03afe63f4d6c73e99c29d5030ff Mon Sep 17 00:00:00 2001 From: matloob Date: Fri, 27 Mar 2026 15:18:29 -0400 Subject: cmd/go/internal/doc: document that -all and -short cannot be combined And return an error message. Hopefully we can add support by the end of the cycle, but for now return an error to avoid confusing users. For #77191 Change-Id: I8a673a4bdfe640a04ec67b8bee0b5a056a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/760304 Reviewed-by: Michael Matloob Reviewed-by: Sean Liao Reviewed-by: Dmitri Shuralyov Auto-Submit: Michael Matloob LUCI-TryBot-Result: Go LUCI --- src/cmd/go/alldocs.go | 3 ++- src/cmd/go/internal/doc/doc.go | 6 +++++- src/cmd/go/testdata/script/doc_all_short.txt | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 src/cmd/go/testdata/script/doc_all_short.txt (limited to 'src') diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go index 8533fd2af1..85a82bc57d 100644 --- a/src/cmd/go/alldocs.go +++ b/src/cmd/go/alldocs.go @@ -457,7 +457,8 @@ // -http // Serve HTML docs over HTTP. // -short -// One-line representation for each symbol. +// One-line representation for each symbol. Cannot be +// combined with -all. // -src // Show the full source code for the symbol. This will // display the full Go source of its declaration and diff --git a/src/cmd/go/internal/doc/doc.go b/src/cmd/go/internal/doc/doc.go index fd6d663375..4acee8ed42 100644 --- a/src/cmd/go/internal/doc/doc.go +++ b/src/cmd/go/internal/doc/doc.go @@ -134,7 +134,8 @@ Flags: -http Serve HTML docs over HTTP. -short - One-line representation for each symbol. + One-line representation for each symbol. Cannot be + combined with -all. -src Show the full source code for the symbol. This will display the full Go source of its declaration and @@ -206,6 +207,9 @@ func do(ctx context.Context, writer io.Writer, flagSet *flag.FlagSet, args []str return err } } + if showAll && short { + return fmt.Errorf("cannot combine -all and -short") + } if serveHTTP { // Special case: if there are no arguments, try to go to an appropriate page // depending on whether we're in a module or workspace. The pkgsite homepage diff --git a/src/cmd/go/testdata/script/doc_all_short.txt b/src/cmd/go/testdata/script/doc_all_short.txt new file mode 100644 index 0000000000..e6a89ec98e --- /dev/null +++ b/src/cmd/go/testdata/script/doc_all_short.txt @@ -0,0 +1,2 @@ +! go doc -all -short +stderr 'doc: cannot combine -all and -short' \ No newline at end of file -- cgit v1.3-5-g9baa