golang/go · error
inconsistent fixes to file %v
Error message
inconsistent fixes to file %v
What it means
In go vet/go fix's zip-merge logic, two separate analyzer runs produced conflicting replacement content for the same file name. The %v is the file name. Indicates analyzers disagree on a fix for one file.
Source
Thrown at src/cmd/go/internal/vet/vet.go:345
// It reports an error if updating the map would change an existing entry.
func readZip(zipfile string, out map[string][]byte) error {
r, err := zip.OpenReader(zipfile)
if err != nil {
return err
}
defer r.Close() // ignore error
for _, f := range r.File {
rc, err := f.Open()
if err != nil {
return err
}
content, err := io.ReadAll(rc)
rc.Close() // ignore error
if err != nil {
return err
}
if prev, ok := out[f.Name]; ok && !bytes.Equal(prev, content) {
return fmt.Errorf("inconsistent fixes to file %v", f.Name)
}
out[f.Name] = content
}
return nil
}
// copyAndDetectDiff copies the tool's stdout to the go command's stdout
// and sets exit status 1 if any output was produced (meaning diffs exist).
// This is used in -diff mode to implement the convention that "go fix -diff"
// exits non-zero when the diff is not empty, consistent with gofmt -d
// and go mod tidy -diff.
func copyAndDetectDiff(r io.Reader) error {
stdouterrMu.Lock()
defer stdouterrMu.Unlock()
n, err := io.Copy(os.Stdout, r)
if err != nil {
return fmt.Errorf("copying diff output: %w", err)
}View on GitHub (pinned to b6b368adc5)
Solutions
- Run analyzers one at a time to identify which conflict
- In -diff mode, review the conflicting patches and apply manually
- Report the conflict to the analyzer author with the file and both patches
Defensive patterns
Strategy: validation
Validate before calling
// As an analyzer author, ensure fixes are idempotent and non-overlapping // Run your analyzer standalone in -fix mode and confirm it converges on a second pass
Prevention
- Make analyzer fixes idempotent (a second run produces no further diff)
- Run conflicting analyzers in separate passes instead of together
When it happens
Trigger: Running multiple fixers (or the same fixer across a package) in -fix mode where two diagnostics target the same file with different patches that don't reconcile.
Common situations: Conflicting gofix/vet analyzers; a custom analyzer that rewrites a file another analyzer also touches; ordering-dependent fixes.
Related errors
- parsing JSON: %v
- parsing JSON diagnostics: %v
- parsing JSON error: %v
- copying diff output: %w
- globalThis.crypto is not available, polyfill required (crypt
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/5b1641c0842ecfa0.
Report an issue: GitHub.