{"record":{"id":"a1bcf9751723fad7","repo":"golang/go","slug":"not-in-module-index","errorCode":null,"errorMessage":"not in module index","messagePattern":"not in module index","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"src/cmd/go/internal/modindex/read.go","lineNumber":121,"sourceCode":"\t\t// is less than modTimeCutoff old.\n\t\t//\n\t\t// This is the same strategy used for hashing test inputs.\n\t\t// See hashOpen in cmd/go/internal/test/test.go for the\n\t\t// corresponding code.\n\t\tinfo, err := d.Info()\n\t\tif err != nil {\n\t\t\treturn cache.ActionID{}, ErrNotIndexed\n\t\t}\n\t\tif info.ModTime().After(cutoff) {\n\t\t\treturn cache.ActionID{}, ErrNotIndexed\n\t\t}\n\n\t\tfmt.Fprintf(h, \"file %v %v %v\\n\", info.Name(), info.ModTime(), info.Size())\n\t}\n\treturn h.Sum(), nil\n}\n\nvar ErrNotIndexed = errors.New(\"not in module index\")\n\nvar (\n\terrDisabled           = fmt.Errorf(\"%w: module indexing disabled\", ErrNotIndexed)\n\terrNotFromModuleCache = fmt.Errorf(\"%w: not from module cache\", ErrNotIndexed)\n\terrFIPS140            = fmt.Errorf(\"%w: fips140 snapshots not indexed\", ErrNotIndexed)\n)\n\n// GetPackage returns the IndexPackage for the directory at the given path.\n// It will return ErrNotIndexed if the directory should be read without\n// using the index, for instance because the index is disabled, or the package\n// is not in a module.\nfunc GetPackage(modroot, pkgdir string) (*IndexPackage, error) {\n\tmi, err := GetModule(modroot)\n\tif err == nil {\n\t\treturn mi.Package(relPath(pkgdir, modroot)), nil\n\t}\n\tif !errors.Is(err, errNotFromModuleCache) {\n\t\treturn nil, err","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modindex/read.go#L103-L139","documentation":"The module index caches parsed package metadata for packages under GOMODCACHE. ErrNotIndexed is returned when a package cannot be served from the index: indexing is disabled, the package is not located inside the module cache, a source file is newer than the index cutoff, or it is a FIPS140 snapshot.","triggerScenarios":"computeIdx or GetPackage finds the package is not eligible for indexing (file ModTime after cutoff, outside the module cache, index disabled, or FIPS140).","commonSituations":"Editing files directly inside GOMODCACHE; index disabled via GODEBUG/GOFLAGS; a replace directive pointing outside the cache; using a stdlib or fips140 package path that is intentionally not indexed.","solutions":["Treat GOMODCACHE as read-only; never edit cached sources directly.","Run `go clean -modcache` to let the index be rebuilt from a clean download.","Confirm the package path is actually inside GOMODCACHE and check GOFLAGS/GODEBUG for index-disabling flags.","If your code handles ErrNotIndexed, fall back to reading the package directly from disk."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never edit source files inside GOMODCACHE; use replace directives or local copies for development.","Treat ErrNotIndexed as a signal to read the package directly from disk rather than the index."],"tags":["go","modules","index","cache"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}