golang/go · info
not in module index
Error message
not in module index
What it means
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.
Source
Thrown at src/cmd/go/internal/modindex/read.go:121
// is less than modTimeCutoff old.
//
// This is the same strategy used for hashing test inputs.
// See hashOpen in cmd/go/internal/test/test.go for the
// corresponding code.
info, err := d.Info()
if err != nil {
return cache.ActionID{}, ErrNotIndexed
}
if info.ModTime().After(cutoff) {
return cache.ActionID{}, ErrNotIndexed
}
fmt.Fprintf(h, "file %v %v %v\n", info.Name(), info.ModTime(), info.Size())
}
return h.Sum(), nil
}
var ErrNotIndexed = errors.New("not in module index")
var (
errDisabled = fmt.Errorf("%w: module indexing disabled", ErrNotIndexed)
errNotFromModuleCache = fmt.Errorf("%w: not from module cache", ErrNotIndexed)
errFIPS140 = fmt.Errorf("%w: fips140 snapshots not indexed", ErrNotIndexed)
)
// GetPackage returns the IndexPackage for the directory at the given path.
// It will return ErrNotIndexed if the directory should be read without
// using the index, for instance because the index is disabled, or the package
// is not in a module.
func GetPackage(modroot, pkgdir string) (*IndexPackage, error) {
mi, err := GetModule(modroot)
if err == nil {
return mi.Package(relPath(pkgdir, modroot)), nil
}
if !errors.Is(err, errNotFromModuleCache) {
return nil, errView on GitHub (pinned to b6b368adc5)
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.
Defensive patterns
Strategy: fallback
Prevention
- 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.
When it happens
Trigger: computeIdx or GetPackage finds the package is not eligible for indexing (file ModTime after cutoff, outside the module cache, index disabled, or FIPS140).
Common situations: 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.
Related errors
- corrupt index
- not a directory
- not completely extracted
- ziphash file is missing
- can only use path@version syntax with 'go get' and 'go insta
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/a1bcf9751723fad7.
Report an issue: GitHub.