{"record":{"id":"087c339faedd08a6","repo":"golang/go","slug":"can-t-read-q-v","errorCode":null,"errorMessage":"can't read %q: %v","messagePattern":"can't read %q: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/cover/html.go","lineNumber":48,"sourceCode":"\tvar d templateData\n\n\tdirs, err := findPkgs(profiles)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor _, profile := range profiles {\n\t\tfn := profile.FileName\n\t\tif profile.Mode == \"set\" {\n\t\t\td.Set = true\n\t\t}\n\t\tfile, err := findFile(dirs, fn)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tsrc, err := os.ReadFile(file)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"can't read %q: %v\", fn, err)\n\t\t}\n\t\tvar buf strings.Builder\n\t\terr = htmlGen(&buf, src, profile.Boundaries(src))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\td.Files = append(d.Files, &templateFile{\n\t\t\tName:     fn,\n\t\t\tBody:     template.HTML(buf.String()),\n\t\t\tCoverage: percentCovered(profile),\n\t\t})\n\t}\n\n\tvar out *os.File\n\tif outfile == \"\" {\n\t\tvar dir string\n\t\tdir, err = os.MkdirTemp(\"\", \"cover\")\n\t\tif err != nil {","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/cover/html.go#L30-L66","documentation":"Thrown by 'go tool cover' html.go when os.ReadFile fails on the source file located for a coverage profile entry during HTML report generation. The wrapped error names the profile's FileName and the underlying read error. findFile has already resolved the path, so failure means the resolved file is missing or unreadable.","triggerScenarios":"`go tool cover -html=profile.out` where a referenced source file no longer exists at the resolved location (findFile returned a path but ReadFile failed).","commonSituations":"Source files deleted/moved after the profile was generated. Running -html in a different checkout. Permission-denied on source files. Generated files (`.cover.go`) cleaned up. Stale profile.","solutions":["Regenerate the profile in the current source tree before producing the HTML report","Run `go tool cover -html` from the same module root as the test","Check read permissions on the source tree"],"exampleFix":"# before\ngo tool cover -html=stale.out\n# after\ngo test -coverprofile=c.out ./...\ngo tool cover -html=c.out -o coverage.html","handlingStrategy":"validation","validationCode":"# Confirm every profile file is readable before -html\nfor f in $(awk '{print $1}' c.out | cut -d: -f1); do\n  [ -r \"$f\" ] || echo \"missing/unreadable: $f\"\ndone","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Generate the HTML report immediately after the test run","Keep the source tree intact between test and report"],"tags":["go-toolchain","cover","html","filesystem","io-error","profile"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}