golangci/golangci-lint · error

conflicting edits from %s and %s on %s first edits: %s secon

Error message

conflicting edits from %s and %s on %s
first edits:
%s
second edits:
%s

What it means

Two issue fixers produced overlapping (conflicting) text edits for the same region of the same file. When the diff3-style merge detects the overlap between the two edit sets, golangci-lint refuses to apply them and reports both edits with unified diffs. This is a deliberate safety check so the fixer never silently corrupts code.

Source

Thrown at pkg/result/processors/fixer.go:304

// edits on a file at path.
// Copy of go/analysis/internal/checker/checker.go
func diff3Conflict(path, xlabel, ylabel string, xedits, yedits []diff.Edit) error {
	contents, err := os.ReadFile(path)
	if err != nil {
		return err
	}
	oldlabel, old := "base", string(contents)

	xdiff, err := diff.ToUnified(oldlabel, xlabel, old, xedits, diff.DefaultContextLines)
	if err != nil {
		return err
	}
	ydiff, err := diff.ToUnified(oldlabel, ylabel, old, yedits, diff.DefaultContextLines)
	if err != nil {
		return err
	}

	return fmt.Errorf("conflicting edits from %s and %s on %s\nfirst edits:\n%s\nsecond edits:\n%s",
		xlabel, ylabel, path, xdiff, ydiff)
}

View on GitHub (pinned to ed7a235d2d)

Solutions

  1. Disable one of the overlapping linters/fixers named in the message (xlabel/ylabel)
  2. Apply one fixer's fix first (run golangci-lint --fix, resolve, run again) so edits no longer overlap
  3. Adjust configuration so each formatting concern is owned by a single linter
  4. If a third-party plugin is involved, update it or report the overlapping edit to its maintainers

Example fix

// before (.golangci.yml)
linters:
  enable: [gofmt, gofumpt, goimports]
// after
linters:
  enable: [gofumpt, goimports]
Defensive patterns

Strategy: validation

Validate before calling

cfg := parseGolangciConfig(".golangci.yml")
formatFixers := []string{"gofmt", "gofumpt", "goimports", "gci"}
var enabled []string
for _, f := range formatFixers {
    if cfg.Linters.Enable[f] { enabled = append(enabled, f) }
}
if len(enabled) > 1 {
    return fmt.Errorf("overlapping fixers enabled: %v", enabled)
}

Prevention

When it happens

Trigger: Running golangci-lint --fix where two enabled linters (e.g. gofmt/gofumpt plus goimports or similar) both want to rewrite overlapping lines of one file, and their edits intersect in the xedits/yedits merge.

Common situations: Enabling multiple formatting linters with overlapping scopes in .golangci.yml (e.g. gofmt + gofumpt + goimports + gci misconfigured); a custom plugin fixer overlapping built-in fixers.

Related errors


AI-assisted analysis of golangci/golangci-lint@ed7a235d2d (2026-09-02). Data as JSON: /api/errors/cc5956d7d8b12c29. Report an issue: GitHub.