Skip to content

ci: gate Go formatting on gofmt - #53

Merged
stxkxs merged 1 commit into
mainfrom
ci/gofmt-gate
Aug 6, 2026
Merged

ci: gate Go formatting on gofmt#53
stxkxs merged 1 commit into
mainfrom
ci/gofmt-gate

Conversation

@stxkxs

@stxkxs stxkxs commented Aug 6, 2026

Copy link
Copy Markdown
Member

What

Enables the gofmt formatter in .golangci.yml, and brings the fourteen files that had drifted back into shape.

Why

Nothing checked Go formatting in this repo. golangci-lint ran with no formatter enabled, so task lint and the CI lint job were both blind to it — and files drifted without any gate noticing: struct-tag alignment, trailing-comment alignment, method-body alignment.

I found it the ordinary way: gofmt -w on a test file I was editing for an unrelated change also realigned a const block that was already unformatted on main.

Why golangci-lint rather than a CI step

golangci-lint run reports an unformatted file as an issue, so the command already wired into task lint and the CI lint job now fails on one. No new step, no new tool, and the local command stays identical to the CI command.

Proven before the cleanup, against the unformatted tree:

internal/audit/runner.go:33:1: File is not properly formatted (gofmt)
internal/baseline/baseline.go:17:1: File is not properly formatted (gofmt)
internal/certs/scanner_test.go:18:1: File is not properly formatted (gofmt)
3 issues:
* gofmt: 3

(exit 1; output caps at three of the same issue, there were fourteen)

The reformat is semantically inert

git diff -w over this change is empty — every Go edit is whitespace. No statement, signature, or tag value moves.

The fourteen files land in the same commit as the gate deliberately: a gate that lands red is a gate someone turns off.

Negative-tested

With the gate enabled, misaligning one trailing comment in internal/cost/diff.go:

state golangci-lint run
clean exit 0
one comment misaligned exit 1
restored exit 0

Verification

task build, task test (26 packages), task lint (0 issues), scripts/check-context.sh, scripts/coverage.sh — all green, every floor met.

Nothing checked Go formatting here. golangci-lint ran without a formatter
enabled, so `task lint` and CI were both blind to it, and files drifted
out of gofmt shape without any gate noticing — struct-tag alignment,
trailing-comment alignment, method-body alignment across fourteen files.

Enables the gofmt formatter in .golangci.yml. `golangci-lint run` reports
an unformatted file as an issue, so the same command already wired into
`task lint` and the CI lint job now fails on one; no new step and no new
tool.

The fourteen files are brought into shape in the same commit, because a
gate that lands red is a gate someone turns off. `git diff -w` over this
change is empty: every Go edit here is whitespace, and no statement,
signature or tag value moves.

Negative-tested: with the gate enabled, misaligning a single trailing
comment fails `golangci-lint run`, and restoring it passes.
@stxkxs
stxkxs merged commit c8bd38b into main Aug 6, 2026
12 checks passed
@stxkxs
stxkxs deleted the ci/gofmt-gate branch August 6, 2026 07:56
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