{"record":{"id":"085000d6be781744","repo":"golang/go","slug":"cannot-combine-all-and-short","errorCode":null,"errorMessage":"cannot combine -all and -short","messagePattern":"cannot combine -all and -short","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/cmd/go/internal/doc/doc.go","lineNumber":218,"sourceCode":"\tmatchCase = false\n\tflagSet.StringVar(&chdir, \"C\", \"\", \"change to `dir` before running command\")\n\tflagSet.BoolVar(&unexported, \"u\", false, \"show unexported symbols as well as exported\")\n\tflagSet.BoolVar(&matchCase, \"c\", false, \"symbol matching honors case (paths not affected)\")\n\tflagSet.BoolVar(&showAll, \"all\", false, \"show all documentation for package\")\n\tflagSet.BoolVar(&showEx, \"ex\", false, \"show executable examples for symbol or package\")\n\tflagSet.BoolVar(&showCmd, \"cmd\", false, \"show symbols with package docs even if package is a command\")\n\tflagSet.BoolVar(&showSrc, \"src\", false, \"show source code for symbol\")\n\tflagSet.BoolVar(&short, \"short\", false, \"one-line representation for each symbol\")\n\tflagSet.BoolVar(&serveHTTP, \"http\", false, \"serve HTML docs over HTTP\")\n\tflagSet.Parse(args)\n\tcounter.CountFlags(\"doc/flag:\", *flagSet)\n\tif chdir != \"\" {\n\t\tif err := os.Chdir(chdir); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tif showAll && short {\n\t\treturn fmt.Errorf(\"cannot combine -all and -short\")\n\t}\n\tif serveHTTP {\n\t\t// Special case: if there are no arguments, try to go to an appropriate page\n\t\t// depending on whether we're in a module or workspace. The pkgsite homepage\n\t\t// is often not the most useful page.\n\t\tif len(flagSet.Args()) == 0 {\n\t\t\tmod, err := runCmd(append(os.Environ(), \"GOWORK=off\"), \"go\", \"list\", \"-m\")\n\t\t\tif err == nil && mod != \"\" && mod != \"command-line-arguments\" {\n\t\t\t\t// If there's a module, go to the module's doc page.\n\t\t\t\treturn doPkgsite(ctx, mod, \"\")\n\t\t\t}\n\t\t\tgowork, err := runCmd(nil, \"go\", \"env\", \"GOWORK\")\n\t\t\tif err == nil && gowork != \"\" {\n\t\t\t\t// Outside a module, but in a workspace, go to the home page\n\t\t\t\t// with links to each of the modules' pages.\n\t\t\t\treturn doPkgsite(ctx, \"\", \"\")\n\t\t\t}\n\t\t\t// Outside a module or workspace, go to the documentation for the standard library.","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/doc/doc.go#L200-L236","documentation":"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.","triggerScenarios":"Invoking `go doc -all -short [pkg]` (in either order); aliasing flags in a wrapper script that sets both.","commonSituations":"Copy-pasted flag combos from different guides; shell aliases or Makefile targets that bolt -all and -short together; tab-completion inserting extra flags.","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."],"exampleFix":"# before\n$ go doc -all -short fmt\n# -> cannot combine -all and -short\n\n# after\n$ go doc -short fmt   # one-line summary\n$ go doc -all fmt     # full docs","handlingStrategy":"validation","validationCode":"hasAll := containsFlag(args, \"-all\")\nhasShort := containsFlag(args, \"-short\")\nif hasAll && hasShort {\n    return errors.New(\"-all and -short are mutually exclusive\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["doc","flags","cli","user-input"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}