{"record":{"id":"710ed23f47081021","repo":"golangci/golangci-lint","slug":"can-t-read-file-s-w","errorCode":null,"errorMessage":"can't read file %s: %w","messagePattern":"can't read file (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/fsutils/filecache.go","lineNumber":27,"sourceCode":")\n\ntype FileCache struct {\n\tfiles sync.Map\n}\n\nfunc NewFileCache() *FileCache {\n\treturn &FileCache{}\n}\n\nfunc (fc *FileCache) GetFileBytes(filePath string) ([]byte, error) {\n\tcachedBytes, ok := fc.files.Load(filePath)\n\tif ok {\n\t\treturn cachedBytes.([]byte), nil\n\t}\n\n\tfileBytes, err := os.ReadFile(filePath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"can't read file %s: %w\", filePath, err)\n\t}\n\n\tfc.files.Store(filePath, fileBytes)\n\treturn fileBytes, nil\n}\n\nfunc PrettifyBytesCount(n int64) string {\n\tconst (\n\t\tMultiplexer = 1024\n\t\tKiB         = 1 * Multiplexer\n\t\tMiB         = KiB * Multiplexer\n\t\tGiB         = MiB * Multiplexer\n\t)\n\n\tif n >= GiB {\n\t\treturn fmt.Sprintf(\"%.1fGiB\", float64(n)/GiB)\n\t}\n\tif n >= MiB {","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/fsutils/filecache.go#L9-L45","documentation":"Error from FileCache.GetFileBytes: os.ReadFile failed for the requested path — the file does not exist, lacks read permission, or is a directory. The path is embedded via %s and the os error wrapped with %w. Generic I/O guard at the file-cache layer.","triggerScenarios":"Thrown at pkg/fsutils/filecache.go:27 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the file path exists and is a regular file","Check file read permissions","Run golangci-lint from the correct working directory","Ensure paths in config (e.g. include/exclude patterns resolving to files) are valid"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}