golang/go · error

%s %s: %v

Error message

%s %s: %v

What it means

Thrown during `go mod verify` when `dirhash.HashZip` fails to compute the hash of the module's zip file. This wraps the underlying hashing error with the module path and version for identification. Hashing can fail if the zip file is corrupted, truncated, or otherwise unreadable.

Source

Thrown at src/cmd/go/internal/modcmd/verify.go:124

	dir, dirErr := modfetch.DownloadDir(ctx, mod)
	data, err := os.ReadFile(zip + "hash")
	if err != nil {
		if zipErr != nil && errors.Is(zipErr, fs.ErrNotExist) &&
			dirErr != nil && errors.Is(dirErr, fs.ErrNotExist) {
			// Nothing downloaded yet. Nothing to verify.
			return nil
		}
		errs = append(errs, fmt.Errorf("%s %s: missing ziphash: %v", mod.Path, mod.Version, err))
		return errs
	}
	h := string(bytes.TrimSpace(data))

	if zipErr != nil && errors.Is(zipErr, fs.ErrNotExist) {
		// ok
	} else {
		hZ, err := dirhash.HashZip(zip, dirhash.DefaultHash)
		if err != nil {
			errs = append(errs, fmt.Errorf("%s %s: %v", mod.Path, mod.Version, err))
			return errs
		} else if hZ != h {
			errs = append(errs, fmt.Errorf("%s %s: zip has been modified (%v)", mod.Path, mod.Version, zip))
		}
	}
	if dirErr != nil && errors.Is(dirErr, fs.ErrNotExist) {
		// ok
	} else {
		hD, err := dirhash.HashDir(dir, mod.Path+"@"+mod.Version, dirhash.DefaultHash)
		if err != nil {

			errs = append(errs, fmt.Errorf("%s %s: %v", mod.Path, mod.Version, err))
			return errs
		}
		if hD != h {
			errs = append(errs, fmt.Errorf("%s %s: dir has been modified (%v)", mod.Path, mod.Version, dir))
		}
	}

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Remove the specific module's cache entry and re-download: `go clean -modcache && go mod download`
  2. Check disk health if corruption recurs across multiple modules
  3. Ensure no concurrent processes are modifying GOMODCACHE

Example fix

// before
go mod verify  // fails hashing corrupt zip
// after
go clean -modcache && go mod download && go mod verify
Defensive patterns

Strategy: retry

Try / catch

// On zip hash failure, attempt cache cleanup and re-download
if err := verifyModule(mod); err != nil {
    goCleanModcache()
    goModDownload(mod)
    verifyModule(mod) // retry once
}

Prevention

When it happens

Trigger: Running `go mod verify` where the zip file exists but is corrupted. `dirhash.HashZip(zip, dirhash.DefaultHash)` returns a non-nil error — e.g., the zip is truncated, has invalid internal structure, or there's an I/O error reading it.

Common situations: Corrupted download (network interruption during zip fetch); disk corruption; manual modification of the zip file; filesystem errors; partial writes from concurrent processes.

Related errors


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