{"record":{"id":"f01831aaf9dd6bfd","repo":"golang/go","slug":"unknown-mode-v","errorCode":null,"errorMessage":"unknown -mode %v","messagePattern":"unknown -mode (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/cover/cover.go","lineNumber":168,"sourceCode":"\tif *mode != \"\" {\n\t\tswitch *mode {\n\t\tcase \"set\":\n\t\t\tcounterStmt = setCounterStmt\n\t\t\tcmode = coverage.CtrModeSet\n\t\tcase \"count\":\n\t\t\tcounterStmt = incCounterStmt\n\t\t\tcmode = coverage.CtrModeCount\n\t\tcase \"atomic\":\n\t\t\tcounterStmt = atomicCounterStmt\n\t\t\tcmode = coverage.CtrModeAtomic\n\t\tcase \"regonly\":\n\t\t\tcounterStmt = nil\n\t\t\tcmode = coverage.CtrModeRegOnly\n\t\tcase \"testmain\":\n\t\t\tcounterStmt = nil\n\t\t\tcmode = coverage.CtrModeTestMain\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"unknown -mode %v\", *mode)\n\t\t}\n\n\t\tif flag.NArg() == 0 {\n\t\t\treturn fmt.Errorf(\"missing source file(s)\")\n\t\t} else {\n\t\t\tif *pkgcfg != \"\" {\n\t\t\t\tif *output != \"\" {\n\t\t\t\t\treturn fmt.Errorf(\"please use '-outfilelist' flag instead of '-o'\")\n\t\t\t\t}\n\t\t\t\tvar err error\n\t\t\t\tif outputfiles, err = readOutFileList(*outfilelist); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tcovervarsoutfile = outputfiles[0]\n\t\t\t\toutputfiles = outputfiles[1:]\n\t\t\t\tnumInputs := len(flag.Args())\n\t\t\t\tnumOutputs := len(outputfiles)\n\t\t\t\tif numOutputs != numInputs {","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/cover/cover.go#L150-L186","documentation":"Thrown by 'go tool cover' parseFlags when -mode is set to a value outside the allowed set. Valid modes are set, count, atomic, regonly, and testmain. Each maps to a counter statement strategy and a coverage.CounterMode; anything else falls through the switch's default branch.","triggerScenarios":"`go tool cover -mode=total` or `-mode=SET` (case-sensitive) or any unrecognized mode string.","commonSituations":"Misspelling a mode name. Using an uppercase variant. Assuming an older/newer mode name exists on this toolchain version (regonly/testmain were added later).","solutions":["Use one of: set, count, atomic, regonly, testmain (lowercase)","Check `go tool cover -help` for the modes supported by your Go version","Upgrade or downgrade Go if a mode you expect is missing"],"exampleFix":"# before\ngo tool cover -mode=total file.go\n# after\ngo tool cover -mode=count file.go","handlingStrategy":"validation","validationCode":"# Validate mode against the allowed enum\nMODES=\"set count atomic regonly testmain\"\nif ! echo \" $MODES \" | grep -q \" $MODE \"; then\n  echo \"unknown -mode $MODE; pick from: $MODES\" >&2; exit 2\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Lowercase only; the switch is case-sensitive","Cross-check available modes with `go tool cover -help` for your Go version"],"tags":["go-toolchain","cover","cli-flags","enum","validation"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}