{"record":{"id":"bf2b60cdee2c0be9","repo":"golang/go","slug":"read-s-v","errorCode":null,"errorMessage":"read %s: %v","messagePattern":"read (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modindex/build.go","lineNumber":274,"sourceCode":"\tf, err := fsys.Open(info.name)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// TODO(matloob) should we decide whether to ignore binary only here or earlier\n\t// when we create the index file?\n\tvar ignoreBinaryOnly bool\n\tif strings.HasSuffix(name, \".go\") {\n\t\terr = readGoInfo(f, info)\n\t\tif strings.HasSuffix(name, \"_test.go\") {\n\t\t\tignoreBinaryOnly = true // ignore //go:binary-only-package comments in _test.go files\n\t\t}\n\t} else {\n\t\tinfo.header, err = readComments(f)\n\t}\n\tf.Close()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"read %s: %v\", info.name, err)\n\t}\n\n\t// Look for +build comments to accept or reject the file.\n\tinfo.goBuildConstraint, info.plusBuildConstraints, info.binaryOnly, err = getConstraints(info.header)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"%s: %v\", name, err)\n\t}\n\n\tif ignoreBinaryOnly && info.binaryOnly {\n\t\tinfo.binaryOnly = false // override info.binaryOnly\n\t}\n\n\treturn info, nil\n}\n\nfunc cleanDecls(m map[string][]token.Position) ([]string, map[string][]token.Position) {\n\tall := make([]string, 0, len(m))\n\tfor path := range m {","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modindex/build.go#L256-L292","documentation":"Wrapped I/O error from getFileInfo during module-index building: the lower-level readGoInfo (for .go files) or readComments (for non-.go files with a recognized extension) returned an error reading the file's bytes. The %s is the joined file path (dir/name) and %v is the underlying error (e.g. permission denied, truncated file).","triggerScenarios":"Indexing a module whose .go or other recognized source file is unreadable: readGoInfo hits a parse/scan error, readComments fails, or fsys.Open succeeded but the subsequent read failed. Reached from getFileInfo in modindex/build.go when err != nil after f.Close().","commonSituations":"File permissions on a checked-out source file are too restrictive; a .go file is mid-write (truncated) when the index is regenerated; filesystem corruption or a broken symlink inside the module cache (GOMODCACHE).","solutions":["Check the file shown in the message: `ls -l <path>` and `cat <path>` to confirm it exists and is readable.","Fix permissions: `chmod -R u+r <module-dir>` or re-run as a user with read access.","Clear and re-download the module: `go clean -modcache && go mod download` to discard a corrupted cache entry.","If the file is being written by another process, wait for it to finish before triggering a build."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-flight check that every .go file is readable before triggering the index build.\nfunc filesReadable(dir string) error {\n    return filepath.WalkDir(dir, func(p string, d fs.DirEntry, err error) error {\n        if err != nil {\n            return err\n        }\n        if d.IsDir() || !strings.HasSuffix(p, \".go\") {\n            return nil\n        }\n        f, err := os.Open(p)\n        if err != nil {\n            return fmt.Errorf(\"unreadable %s: %w\", p, err)\n        }\n        f.Close()\n        return nil\n    })\n}","typeGuard":null,"tryCatchPattern":"// go/build and the module index surface read errors as standard errors;\n// wrap the call to add context for end users.\npkg, err := modindex.OpenPackage(modroot, dir)\nif err != nil {\n    var pathErr *fs.PathError\n    if errors.As(err, &pathErr) {\n        // permission / ENOENT: surface to the user, optionally clear cache.\n        return fmt.Errorf(\"source unreadable (%s) — check perms or run `go clean -modcache`\", pathErr.Path)\n    }\n    return err\n}","preventionTips":["Keep GOMODCACHE on a healthy local filesystem.","Avoid editing module-cache files directly.","Run `go mod verify` periodically to catch corruption early."],"tags":["module-index","filesystem","io"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}