{"record":{"id":"efb628f9134403ea","repo":"golang/go","slug":"error-reading-outfilelist-file-q-v","errorCode":null,"errorMessage":"error reading -outfilelist file %q: %v","messagePattern":"error reading -outfilelist file %q: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/cover/cover.go","lineNumber":211,"sourceCode":"\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}\n\tswitch pkgconfig.Granularity {\n\tcase \"perblock\":\n\t\tcgran = coverage.CtrGranularityPerBlock\n\tcase \"perfunc\":\n\t\tcgran = coverage.CtrGranularityPerFunc\n\tdefault:","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/cover/cover.go#L193-L229","documentation":"Thrown by 'go tool cover' readOutFileList when os.ReadFile fails on the path given to -outfilelist. The wrapped error includes the path and the underlying OS error (e.g. file not found, permission denied). The file is expected to contain one output path per line.","triggerScenarios":"`go tool cover -mode=set -pkgcfg=p.cfg -outfilelist=/nonexistent/files.txt input.go`, or pointing -outfilelist at an unreadable/permission-denied file.","commonSituations":"Wrong working directory producing a relative path that doesn't resolve. Stale path from a previous build. Permissions issue in CI sandboxes. Typo in the path.","solutions":["Verify the -outfilelist path exists and is readable before invoking cover","Use an absolute path to avoid working-directory issues","Check file permissions if running under a restricted user/CI"],"exampleFix":"# before (path wrong / missing)\ngo tool cover -mode=set -pkgcfg=p.cfg -outfilelist=out.txt input.go\n# after\ngo tool cover -mode=set -pkgcfg=p.cfg -outfilelist=/abs/path/out.txt input.go","handlingStrategy":"validation","validationCode":"# Validate outfilelist is readable before calling cover\nif [ ! -r \"$OUTFILELIST\" ]; then echo \"cannot read -outfilelist $OUTFILELIST\" >&2; exit 2; fi","typeGuard":null,"tryCatchPattern":"// Go caller of readOutFileList:\ndata, err := os.ReadFile(path)\nif err != nil { return nil, fmt.Errorf(\"unreadable outfilelist %q: %w\", path, err) }","preventionTips":["Use absolute paths for -outfilelist","Create the file in the same build step that invokes cover"],"tags":["go-toolchain","cover","filesystem","pkgcfg","io-error"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}