{"record":{"id":"5b1641c0842ecfa0","repo":"golang/go","slug":"inconsistent-fixes-to-file-v","errorCode":null,"errorMessage":"inconsistent fixes to file %v","messagePattern":"inconsistent fixes to file (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/vet/vet.go","lineNumber":345,"sourceCode":"// It reports an error if updating the map would change an existing entry.\nfunc readZip(zipfile string, out map[string][]byte) error {\n\tr, err := zip.OpenReader(zipfile)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer r.Close() // ignore error\n\tfor _, f := range r.File {\n\t\trc, err := f.Open()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tcontent, err := io.ReadAll(rc)\n\t\trc.Close() // ignore error\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif prev, ok := out[f.Name]; ok && !bytes.Equal(prev, content) {\n\t\t\treturn fmt.Errorf(\"inconsistent fixes to file %v\", f.Name)\n\t\t}\n\t\tout[f.Name] = content\n\t}\n\treturn nil\n}\n\n// copyAndDetectDiff copies the tool's stdout to the go command's stdout\n// and sets exit status 1 if any output was produced (meaning diffs exist).\n// This is used in -diff mode to implement the convention that \"go fix -diff\"\n// exits non-zero when the diff is not empty, consistent with gofmt -d\n// and go mod tidy -diff.\nfunc copyAndDetectDiff(r io.Reader) error {\n\tstdouterrMu.Lock()\n\tdefer stdouterrMu.Unlock()\n\tn, err := io.Copy(os.Stdout, r)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"copying diff output: %w\", err)\n\t}","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/vet/vet.go#L327-L363","documentation":"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.","triggerScenarios":"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.","commonSituations":"Conflicting gofix/vet analyzers; a custom analyzer that rewrites a file another analyzer also touches; ordering-dependent fixes.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// As an analyzer author, ensure fixes are idempotent and non-overlapping\n// Run your analyzer standalone in -fix mode and confirm it converges on a second pass","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make analyzer fixes idempotent (a second run produces no further diff)","Run conflicting analyzers in separate passes instead of together"],"tags":["go","vet","fix","analyzer"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}