{"record":{"id":"632b138a372b7d4a","repo":"golang/go","slug":"missing-source-file-s","errorCode":null,"errorMessage":"missing source file(s)","messagePattern":"missing source file\\(s\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/cover/cover.go","lineNumber":172,"sourceCode":"\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 {\n\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","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/cover/cover.go#L154-L190","documentation":"Thrown by 'go tool cover' parseFlags when -mode is set but no Go source file arguments are supplied (flag.NArg() == 0). Instrumentation mode requires at least one input .go file to annotate; with zero files there is nothing to do.","triggerScenarios":"`go tool cover -mode=set` with no trailing file arguments.","commonSituations":"Glob in a shell script expanding to nothing. Forgetting to pass the package's files. Running the tool manually to test a flag without providing input.","solutions":["Append the .go file(s) or a glob that resolves to at least one file","Verify your file list/glob is non-empty before invoking the tool","Use the -pkgcfg workflow when instrumenting a whole package via the go command"],"exampleFix":"# before\ngo tool cover -mode=set\n# after\ngo tool cover -mode=set main.go lib.go","handlingStrategy":"validation","validationCode":"# Ensure at least one input file before invoking in -mode\nfiles=(src/*.go)\nif [ ${#files[@]} -eq 0 ]; then echo \"no source files\" >&2; exit 2; fi\ngo tool cover -mode=set \"${files[@]}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Glob-expand and count inputs in your build script","Use `nullglob` awareness in bash to detect empty globs"],"tags":["go-toolchain","cover","cli-flags","missing-argument"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}