golang/go · warning
cannot combine -all and -short
Error message
cannot combine -all and -short
What it means
Returned by the `go doc` flag handler when both -all (full recursive docs) and -short (one-line per symbol) are passed. The two flags are semantically mutually exclusive — -all expands everything while -short collapses to a summary — so combining them is a user error caught right after flagSet.Parse.
Source
Thrown at src/cmd/go/internal/doc/doc.go:218
matchCase = false
flagSet.StringVar(&chdir, "C", "", "change to `dir` before running command")
flagSet.BoolVar(&unexported, "u", false, "show unexported symbols as well as exported")
flagSet.BoolVar(&matchCase, "c", false, "symbol matching honors case (paths not affected)")
flagSet.BoolVar(&showAll, "all", false, "show all documentation for package")
flagSet.BoolVar(&showEx, "ex", false, "show executable examples for symbol or package")
flagSet.BoolVar(&showCmd, "cmd", false, "show symbols with package docs even if package is a command")
flagSet.BoolVar(&showSrc, "src", false, "show source code for symbol")
flagSet.BoolVar(&short, "short", false, "one-line representation for each symbol")
flagSet.BoolVar(&serveHTTP, "http", false, "serve HTML docs over HTTP")
flagSet.Parse(args)
counter.CountFlags("doc/flag:", *flagSet)
if chdir != "" {
if err := os.Chdir(chdir); err != nil {
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
// is often not the most useful page.
if len(flagSet.Args()) == 0 {
mod, err := runCmd(append(os.Environ(), "GOWORK=off"), "go", "list", "-m")
if err == nil && mod != "" && mod != "command-line-arguments" {
// If there's a module, go to the module's doc page.
return doPkgsite(ctx, mod, "")
}
gowork, err := runCmd(nil, "go", "env", "GOWORK")
if err == nil && gowork != "" {
// Outside a module, but in a workspace, go to the home page
// with links to each of the modules' pages.
return doPkgsite(ctx, "", "")
}
// Outside a module or workspace, go to the documentation for the standard library.View on GitHub (pinned to b6b368adc5)
Solutions
- Pick one: use -all for full docs or -short for a summary, not both.
- Audit shell aliases / Makefile targets for conflicting flag pairs.
- Drop one flag from the command line and retry.
Example fix
# before $ go doc -all -short fmt # -> cannot combine -all and -short # after $ go doc -short fmt # one-line summary $ go doc -all fmt # full docs
Defensive patterns
Strategy: validation
Validate before calling
hasAll := containsFlag(args, "-all")
hasShort := containsFlag(args, "-short")
if hasAll && hasShort {
return errors.New("-all and -short are mutually exclusive")
} Prevention
- Do not alias -all and -short together.
- Audit wrapper scripts/aliases for conflicting go doc flags.
- Prefer -short for quick overviews, -all for deep dives.
When it happens
Trigger: Invoking `go doc -all -short [pkg]` (in either order); aliasing flags in a wrapper script that sets both.
Common situations: Copy-pasted flag combos from different guides; shell aliases or Makefile targets that bolt -all and -short together; tab-completion inserting extra flags.
Related errors
- -C flag must be first flag on command line
- no such package: %s
- no symbol %s in package%s
- pattern %q does not specify a single package
- error: cannot use -w with standard input
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/085000d6be781744.
Report an issue: GitHub.