golang/go · info · entryNotFoundError

gocacheverify=1

Error message

gocacheverify=1

What it means

errVerifyMode ('gocacheverify=1') is a deliberate sentinel error, not a real failure. When GODEBUG=gocacheverify=1 is set, DiskCache.Get unconditionally returns errMissing wrapping errVerifyMode so that every cache lookup misses; subsequent Put calls then compare the freshly computed output against any existing entry to detect non-determinism (cases where the build would have produced a different result had the cache hit been used).

Source

Thrown at src/cmd/go/internal/cache/cache.go:155

const (
	// action entry file is "v1 <hex id> <hex out> <decimal size space-padded to 20 bytes> <unixnano space-padded to 20 bytes>\n"
	hexSize   = HashSize * 2
	entrySize = 2 + 1 + hexSize + 1 + hexSize + 1 + 20 + 1 + 20 + 1
)

// verify controls whether to run the cache in verify mode.
// In verify mode, the cache always returns errMissing from Get
// but then double-checks in Put that the data being written
// exactly matches any existing entry. This provides an easy
// way to detect program behavior that would have been different
// had the cache entry been returned from Get.
//
// verify is enabled by setting the environment variable
// GODEBUG=gocacheverify=1.
var verify = false

var errVerifyMode = errors.New("gocacheverify=1")

// DebugTest is set when GODEBUG=gocachetest=1 is in the environment.
var DebugTest = false

func init() { initEnv() }

var (
	gocacheverify = godebug.New("gocacheverify")
	gocachehash   = godebug.New("gocachehash")
	gocachetest   = godebug.New("gocachetest")
)

func initEnv() {
	if gocacheverify.Value() == "1" {
		gocacheverify.IncNonDefault()
		verify = true
	}
	if gocachehash.Value() == "1" {

View on GitHub (pinned to b6b368adc5)

Solutions

  1. If you set it intentionally, finish debugging and unset GODEBUG=gocacheverify=1 to restore normal caching.
  2. If builds are mysteriously slow and every action rebuilds, check for a leftover GODEBUG=gocacheverify=1 in your environment.
  3. Clear the cache (`go clean -cache`) after toggling the flag to start from a clean baseline.

Example fix

// before (debug mode left on, every build recomputes)
export GODEBUG=gocacheverify=1
go build ./...
// after
unset GODEBUG
go build ./...
Defensive patterns

Strategy: validation

Validate before calling

// Warn if gocacheverify is left enabled, since it disables all cache hits.
import "os"
func cacheVerifyEnabled() bool {
    return os.Getenv("GODEBUG") == "gocacheverify=1" ||
        strings.Contains(os.Getenv("GODEBUG"), "gocacheverify=1")
}

Prevention

When it happens

Trigger: Setting the environment variable GODEBUG=gocacheverify=1 and running any go command that uses the build cache (go build/test/install). Every Get returns this error, forcing recomputation and write-time verification.

Common situations: Debugging build-cache correctness during Go toolchain development; investigating suspected non-deterministic builds; accidentally leaving GODEBUG=gocacheverify=1 in a CI or shell profile, which makes all builds dramatically slower.

Related errors


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