golang/go · error

finding %s: %w

Error message

finding %s: %w

What it means

While reconstructing the compiled-Go-file list from cache, loadCachedCompiledGoFiles calls findCachedObjdirFile for each manifest entry that is not a local (./) path. If locating that file in the cache fails, this wraps the underlying error with the file's logical name. It means the srcfiles manifest references a file the cache cannot supply.

Source

Thrown at src/cmd/go/internal/work/exec.go:1425

	c := cache.Default()
	list, _, err := cache.GetBytes(c, cache.Subkey(a.actionID, "srcfiles"))
	if err != nil {
		return fmt.Errorf("reading srcfiles list: %w", err)
	}
	var gofiles []string
	for name := range strings.SplitSeq(string(list), "\n") {
		if name == "" { // end of list
			continue
		} else if !strings.HasSuffix(name, ".go") {
			continue
		}
		if strings.HasPrefix(name, "./") {
			gofiles = append(gofiles, name[len("./"):])
			continue
		}
		file, err := b.findCachedObjdirFile(a, c, name)
		if err != nil {
			return fmt.Errorf("finding %s: %w", name, err)
		}
		gofiles = append(gofiles, file)
	}
	a.Package.CompiledGoFiles = gofiles
	return nil
}

// vetConfig is the configuration passed to vet describing a single package.
type vetConfig struct {
	ID           string   // package ID (example: "fmt [fmt.test]")
	Compiler     string   // compiler name (gc, gccgo)
	Dir          string   // directory containing package
	ImportPath   string   // canonical import path ("package path")
	GoFiles      []string // absolute paths to package source files
	NonGoFiles   []string // absolute paths to package non-Go files
	IgnoredFiles []string // absolute paths to ignored source files

	Module      *analysis.Module  // module information, if any

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Run `go clean -cache` and rebuild
  2. Check for concurrent builds or a cache directory on NFS/FUSE
  3. Verify free disk space on the cache partition

Example fix

// before
go build ./...
// after
go clean -cache && go build ./...
Defensive patterns

Strategy: retry

Try / catch

// On a missing cached objdir file, clean and retry
if bytes.Contains(out, []byte("finding")) && bytes.Contains(out, []byte(": ")) {
    exec.Command("go", "clean", "-cache").Run()
    out, err = cmd.CombinedOutput()
}

Prevention

When it happens

Trigger: Fires inside the `for name := range strings.SplitSeq(string(list), "\n")` loop of loadCachedCompiledGoFiles when b.findCachedObjdirFile(a, c, name) returns an error for a generated (non-local) file such as a _cgo_*.go artifact.

Common situations: A srcfiles manifest pointing at a file missing from the cache due to partial writes, eviction, or corruption; common with cgo packages on flaky cache storage.

Related errors


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