{"record":{"id":"d19b0aa2b350de35","repo":"golang/go","slug":"verifying-go-mod-v","errorCode":null,"errorMessage":"verifying go.mod: %v","messagePattern":"verifying go\\.mod: (.+?)","errorType":"exception","errorClass":"module.ModuleError","httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modfetch/fetch.go","lineNumber":748,"sourceCode":"\n\tif err := checkModSum(f, mod, h); err != nil {\n\t\tbase.Fatalf(\"%s\", err)\n\t}\n}\n\n// goModSum returns the checksum for the go.mod contents.\nfunc goModSum(data []byte) (string, error) {\n\treturn dirhash.Hash1([]string{\"go.mod\"}, func(string) (io.ReadCloser, error) {\n\t\treturn io.NopCloser(bytes.NewReader(data)), nil\n\t})\n}\n\n// checkGoMod checks the given module's go.mod checksum;\n// data is the go.mod content.\nfunc checkGoMod(f *Fetcher, path, version string, data []byte) error {\n\th, err := goModSum(data)\n\tif err != nil {\n\t\treturn &module.ModuleError{Path: path, Version: version, Err: fmt.Errorf(\"verifying go.mod: %v\", err)}\n\t}\n\n\treturn checkModSum(f, module.Version{Path: path, Version: version + \"/go.mod\"}, h)\n}\n\n// checkModSum checks that the recorded checksum for mod is h.\n//\n// mod.Version may have the additional suffix \"/go.mod\" to request the checksum\n// for the module's go.mod file only.\nfunc checkModSum(f *Fetcher, mod module.Version, h string) error {\n\t// We lock goSum when manipulating it,\n\t// but we arrange to release the lock when calling checkSumDB,\n\t// so that parallel calls to checkModHash can execute parallel calls\n\t// to checkSumDB.\n\n\t// Check whether mod+h is listed in go.sum already. If so, we're done.\n\tf.mu.Lock()\n\tinited, err := f.initGoSum()","sourceCodeStart":730,"sourceCodeEnd":766,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modfetch/fetch.go#L730-L766","documentation":"checkGoMod computes the h1 hash of the go.mod bytes via goModSum and, if hashing itself fails, wraps the underlying error as a ModuleError with 'verifying go.mod:'. This is a wrapping of an unexpected hashing/IO failure, not a checksum mismatch (mismatch surfaces via checkModSum downstream).","triggerScenarios":"dirhash.Hash1 returns an error while reading the go.mod content — e.g. the function passed to Hash1 returned an error, which for goModSum only happens on an internal allocation/IO failure.","commonSituations":"Extremely rare in practice; seen with OOM during hashing or a corrupted in-memory copy after a partial read. Usually indicates a bug in surrounding glue rather than user input.","solutions":["Re-run the command — transient memory/IO pressure may clear it.","Clear go.sum and modcache for the module and retry cleanly.","File an issue with the full go.mod content if it reproduces, since hash failures here are not user-driven."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := modfetch.CheckGoMod(...); err != nil {\n    var me *module.ModuleError\n    if errors.As(err, &me) {\n        // log and retry once; this path usually reflects transient hashing failures\n    }\n}","preventionTips":["Treat this as a transient/internal bug: retry before escalating.","Keep go.mod content ASCII and small to avoid hashing edge cases."],"tags":["checksum","go-mod","hashing"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}