{"record":{"id":"4ff20f0d725414cd","repo":"golang/go","slug":"too-many-options","errorCode":null,"errorMessage":"too many options","messagePattern":"too many options","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/cover/cover.go","lineNumber":136,"sourceCode":"\t// Output HTML or function coverage information.\n\tif *htmlOut != \"\" {\n\t\terr = htmlOutput(profile, *output)\n\t} else {\n\t\terr = funcOutput(profile, *output)\n\t}\n\n\tif err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"cover: %v\\n\", err)\n\t\tos.Exit(2)\n\t}\n}\n\n// parseFlags sets the profile and counterStmt globals and performs validations.\nfunc parseFlags() error {\n\tprofile = *htmlOut\n\tif *funcOut != \"\" {\n\t\tif profile != \"\" {\n\t\t\treturn fmt.Errorf(\"too many options\")\n\t\t}\n\t\tprofile = *funcOut\n\t}\n\n\t// Must either display a profile or rewrite Go source.\n\tif (profile == \"\") == (*mode == \"\") {\n\t\treturn fmt.Errorf(\"too many options\")\n\t}\n\n\tif *varVar != \"\" && !token.IsIdentifier(*varVar) {\n\t\treturn fmt.Errorf(\"-var: %q is not a valid identifier\", *varVar)\n\t}\n\n\tif *mode != \"\" {\n\t\tswitch *mode {\n\t\tcase \"set\":\n\t\t\tcounterStmt = setCounterStmt\n\t\t\tcmode = coverage.CtrModeSet","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/cover/cover.go#L118-L154","documentation":"Thrown by 'go tool cover' parseFlags when both -html and -func flags are set to non-empty values. The tool only allows one output mode at a time (HTML coverage report OR per-function coverage percentages). Setting both is treated as conflicting/ambiguous input.","triggerScenarios":"Invoking `go tool cover -html=profile.out -func=profile.out` (or any invocation where both -html and -func are non-empty). The first branch: profile is set from htmlOut, and if funcOut is also set the error fires.","commonSituations":"User typo combining flags meant to be alternatives. Copy-pasting a command that had one mode and appending another. Scripts that template flags conditionally without mutual exclusion.","solutions":["Choose exactly one of -html or -func per invocation","Run two separate `go tool cover` commands if you need both outputs","Wrap the invocation so the two flags are mutually exclusive (e.g. shell case/if)"],"exampleFix":"# before\ngo tool cover -html=c.out -func=c.out\n# after\ngo tool cover -html=c.out -o coverage.html\ngo tool cover -func=c.out","handlingStrategy":"validation","validationCode":"# Shell: enforce mutual exclusion before invoking cover\nif [ -n \"$HTML\" ] && [ -n \"$FUNC\" ]; then\n  echo \"use only one of -html or -func\" >&2; exit 2\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat -html and -func as alternatives, never combined","Document the single-mode invariant in build scripts"],"tags":["go-toolchain","cover","cli-flags","flag-conflict"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}