Skip to content

feat(golangci): enforce gofumpt (-extra) + gci import grouping#83

Merged
cplieger merged 2 commits into
mainfrom
feat/golangci-formatters-gofumpt-gci
Jun 8, 2026
Merged

feat(golangci): enforce gofumpt (-extra) + gci import grouping#83
cplieger merged 2 commits into
mainfrom
feat/golangci-formatters-gofumpt-gci

Conversation

@cplieger

@cplieger cplieger commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Why

golangci-lint v2 moved gofmt/gofumpt/gci out of linters into a separate formatters category that this config never enabled, and go-ci.yaml only runs golangci-lint run with no fmt gate. Result: formatting drift accumulated silently fleet-wide (~38 unformatted Go files in vibekit alone; golangci-lint run reported 0 issues on them).

What

Enable formatters in the canonical synced .golangci.yaml:

  • gofumpt with extra-rules: true — strictest (groups adjacent same-type params, forbids naked returns) on top of gofumpt's strict superset of gofmt. module-path auto-detected per repo.
  • gci with sections: [standard, default, localmodule] + custom-order: true — deterministic std → third-party → local-module grouping. localmodule auto-reads each repo's go.mod, so it's uniform for both app modules (vibekit) and lib modules (github.com/cplieger/x).

goimports is intentionally not enabled: it conflicts with gci on ordering, and its only unique capability (add/remove imports) is moot in CI (the compiler rejects unused/missing) and is handled by gopls in editors.

Enforcement & propagation

  • No workflow change / version bump / Renovate-digest needed. golangci-lint run reports enabled formatters as issues (verified on v2.12.2: File is not properly formatted (gci), exit 1), so the existing lint step enforces this once the config propagates via sync.yaml to every Go repo.
  • Each Go repo needs a one-time golangci-lint fmt sweep. Sync PRs self-gate: a repo's chore(sync) PR fails CI until that repo is formatted, so land the per-repo sweep first (or alongside). vibekit's sweep is in flight.

Validated: golangci-lint config verify clean; golangci-lint fmt --diff exits 1 on drift.

golangci-lint v2 moved gofmt/gofumpt/gci out of linters into a separate formatters category that was never enabled, and the workflow only runs 'golangci-lint run' with no fmt gate — so formatting drift accumulated silently across the fleet (~38 unformatted files found in vibekit alone).

Enable formatters in the canonical synced config: gofumpt with extra-rules (group adjacent same-type params, forbid naked returns) + gci with sections [standard, default, localmodule] and custom-order (deterministic std -> third-party -> local-module grouping; localmodule auto-reads each repo's go.mod). goimports is intentionally not enabled — it conflicts with gci on ordering and its add/remove is moot in CI (compiler rejects unused/missing) and handled by gopls in editors.

No workflow change needed: 'golangci-lint run' reports enabled formatters as issues (verified, exit 1 on v2.12.2), so the existing lint step enforces this once the config propagates via sync.yaml. Each Go repo needs a one-time 'golangci-lint fmt' sweep; sync PRs self-gate (fail CI until the repo is formatted).
gofumpt folds first-party imports into the third-party group and never emits a separate local-import group, so gci localmodule/prefix sections can't converge with gofumpt (verified: domainless and domain repos both oscillated). [standard, default] converges for both domain libs and (domain-renamed) apps.
This was referenced Jun 8, 2026
cplieger added a commit to cplieger/auth that referenced this pull request Jun 8, 2026
Apply the formatters now enforced centrally (cplieger/ci#83): gofumpt extra-rules + gci [standard, default]. Mechanical formatting only; build/vet/test verified.
cplieger added a commit to cplieger/httpx that referenced this pull request Jun 8, 2026
Apply the formatters now enforced centrally (cplieger/ci#83): gofumpt extra-rules + gci [standard, default]. Mechanical formatting only; build/vet/test verified.
cplieger added a commit to cplieger/ssrf that referenced this pull request Jun 8, 2026
Apply the formatters now enforced centrally (cplieger/ci#83): gofumpt extra-rules + gci [standard, default]. Mechanical formatting only; build/vet/test verified.
cplieger added a commit to cplieger/vterm that referenced this pull request Jun 8, 2026
Apply the formatters now enforced centrally (cplieger/ci#83): gofumpt extra-rules + gci [standard, default]. Mechanical formatting only; build/vet/test verified.
@cplieger cplieger merged commit 519a0cd into main Jun 8, 2026
1 check passed
@cplieger cplieger deleted the feat/golangci-formatters-gofumpt-gci branch June 8, 2026 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant