{"record":{"id":"c10238bf84f67514","repo":"golang/go","slug":"too-many-arguments","errorCode":null,"errorMessage":"too many arguments","messagePattern":"too many arguments","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/cover/cover.go","lineNumber":205,"sourceCode":"\t\t\t\t\treturn fmt.Errorf(\"number of output files (%d) not equal to number of input files (%d)\", numOutputs, numInputs)\n\t\t\t\t}\n\t\t\t\tif err := readPackageConfig(*pkgcfg); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t} else {\n\t\t\t\tif *outfilelist != \"\" {\n\t\t\t\t\treturn fmt.Errorf(\"'-outfilelist' flag applicable only when -pkgcfg used\")\n\t\t\t\t}\n\t\t\t}\n\t\t\tif flag.NArg() == 1 {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t} else if flag.NArg() == 0 {\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"too many arguments\")\n}\n\nfunc readOutFileList(path string) ([]string, error) {\n\tdata, err := os.ReadFile(path)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error reading -outfilelist file %q: %v\", path, err)\n\t}\n\treturn strings.Split(strings.TrimSpace(string(data)), \"\\n\"), nil\n}\n\nfunc readPackageConfig(path string) error {\n\tdata, err := os.ReadFile(path)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error reading pkgconfig file %q: %v\", path, err)\n\t}\n\tif err := json.Unmarshal(data, &pkgconfig); err != nil {\n\t\treturn fmt.Errorf(\"error reading pkgconfig file %q: %v\", path, err)\n\t}","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/cover/cover.go#L187-L223","documentation":"Thrown by 'go tool cover' parseFlags as a catch-all when, in source-instrumentation mode (-mode set), more than one input file is given WITHOUT -pkgcfg. Without -pkgcfg the tool only supports a single source file; multiple files require the -pkgcfg package workflow.","triggerScenarios":"`go tool cover -mode=set a.go b.go` (two files, no -pkgcfg).","commonSituations":"Trying to instrument a whole package directly with `go tool cover` instead of through the go command. Passing a glob that expands to multiple files.","solutions":["Pass exactly one .go file when not using -pkgcfg","For multi-file packages, use the -pkgcfg + -outfilelist workflow (normally driven by `go build -cover`)"],"exampleFix":"# before\ngo tool cover -mode=set a.go b.go\n# after (single file)\ngo tool cover -mode=set a.go\n# or use the package workflow via the go command:\ngo build -cover ./...","handlingStrategy":"validation","validationCode":"# Without -pkgcfg, allow exactly one input\nif [ -z \"$PKGCFG\" ] && [ \"$#\" -ne 1 ]; then\n  echo \"single-file mode needs exactly one input; use -pkgcfg for packages\" >&2; exit 2\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use `go build -cover` for whole-package instrumentation","Reserve direct `go tool cover` single-file use for ad-hoc checks"],"tags":["go-toolchain","cover","cli-flags","too-many-arguments"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}