aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormatloob <matloob@golang.org>2026-03-27 15:18:29 -0400
committerGopher Robot <gobot@golang.org>2026-03-30 09:07:22 -0700
commit7dbbeea110b8e03afe63f4d6c73e99c29d5030ff (patch)
treed5dabb08a123d8e8c87377721bec9973592f8672 /src
parentdadc8a5cd274a7d70542d36fa1dfbeb112197988 (diff)
downloadgo-7dbbeea110b8e03afe63f4d6c73e99c29d5030ff.tar.xz
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 <matloob@google.com> Reviewed-by: Sean Liao <sean@liao.dev> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Michael Matloob <matloob@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/go/alldocs.go3
-rw-r--r--src/cmd/go/internal/doc/doc.go6
-rw-r--r--src/cmd/go/testdata/script/doc_all_short.txt2
3 files changed, 9 insertions, 2 deletions
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