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, err

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Treat GOMODCACHE as read-only; never edit cached sources directly.
  2. Run `go clean -modcache` to let the index be rebuilt from a clean download.
  3. Confirm the package path is actually inside GOMODCACHE and check GOFLAGS/GODEBUG for index-disabling flags.
  4. If your code handles ErrNotIndexed, fall back to reading the package directly from disk.
Defensive patterns

Strategy: fallback

Prevention

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


AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12). Data as JSON: /api/errors/a1bcf9751723fad7. Report an issue: GitHub.