{"record":{"id":"c8188d34044aad0c","repo":"golangci/golangci-lint","slug":"failed-to-compute-go-sum-w","errorCode":null,"errorMessage":"failed to compute go.sum: %w","messagePattern":"failed to compute go\\.sum: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/commands/run.go","lineNumber":721,"sourceCode":"func computeGoModSalt() (string, error) {\n\tvalues, err := goenv.Get(context.Background(), goenv.GOMOD)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get goenv: %w\", err)\n\t}\n\n\tgoModPath := filepath.Clean(values[goenv.GOMOD])\n\n\tdata, err := os.ReadFile(goModPath)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to read go.mod: %w\", err)\n\t}\n\n\t// NOTE: the variable `goModPath` is not used here to ensure getting the same hash, independently of the location, for the same content.\n\tsum, err := dirhash.Hash1([]string{\"go.mod\"}, func(string) (io.ReadCloser, error) {\n\t\treturn io.NopCloser(bytes.NewReader(data)), nil\n\t})\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to compute go.sum: %w\", err)\n\t}\n\n\treturn sum, nil\n}\n","sourceCodeStart":703,"sourceCodeEnd":726,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/commands/run.go#L703-L726","documentation":"After reading go.mod, computeGoModSalt computes a dirhash.Hash1 over its contents. If dirhash.Hash1 itself errors (unexpected here since it hashes an in-memory single file), the failure is wrapped with this message, again aborting hash-salt computation.","triggerScenarios":"dirhash.Hash1 failing during cache salt initialization; in practice nearly unreachable because the Open function returns io.NopCloser over an in-memory reader that cannot fail.","commonSituations":"Theoretically surfaced in exotic environments where the stdlib dirhash implementation returns an error; developers seeing it should check the wrapped cause.","solutions":["Inspect the wrapped cause in the error message for the real failure","Update to a recent golangci-lint version to rule out a stdlib/dirhash regression","If persistent, clear the lint cache (`golangci-lint cache clean`) and retry"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := runLint(); err != nil {\n\tif strings.Contains(err.Error(), \"failed to compute go.sum\") {\n\t\t// inspect wrapped cause; clear cache and retry once\n\t\trunCacheClean()\n\t\terr = runLint()\n\t}\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n}","preventionTips":["Keep golangci-lint and Go toolchain versions up to date","If seen repeatedly, run `golangci-lint cache clean` and retry","Report persistent occurrences with the wrapped cause to maintainers"],"tags":["go","golangci-lint","cache","hashing"],"backgroundTag":"hash-computation-failed","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}