Skip to content

Check gofmt in CI - #19

Merged
Wasabules merged 1 commit into
mainfrom
ci-gofmt
Sep 6, 2026
Merged

Check gofmt in CI#19
Wasabules merged 1 commit into
mainfrom
ci-gofmt

Conversation

@Wasabules

Copy link
Copy Markdown
Owner

Neither go vet nor staticcheck checks formatting, so nothing in CI did — which
is how two files drifted and stayed drifted.

The two deviations

Both are struct field alignment, and both predate this branch — they come from
7b9436e Project restructuration:

  • internal/pki/manager_test.go — a field list in TestGenerateCA_RespectsOptions
  • internal/storage/config_test.go — a literal in TestValidateServerConfig_PortConflict

gofmt -w on those two: 16 lines, no behaviour change.

The step

Added to the quality job, before npm cigofmt -l walks the tree, and
node_modules has no business being in that walk. On failure it prints both the
offending files and the diff, so the fix is gofmt -w on exactly what it names.

A trap worth knowing about

Running gofmt -l locally on Windows flags files that CI reports clean. The
working copy is CRLF (core.autocrlf) while gofmt expects LF, so entire files
come back as "unformatted".

Locally this listed four files; a checkout made with core.autocrlf=false listed
two — and those two were the real ones. That is how the genuine deviations were
told apart from the artefacts, and it is written into the step's comment so the
next person does not chase the same ghosts.

Verified by replaying the exact step against an LF checkout of this branch: no
files reported.

Neither `go vet` nor staticcheck checks formatting, so nothing in CI did — which
is how two files drifted and stayed drifted.

Both deviations are struct field alignment and predate this branch (they come
from `7b9436e Project restructuration`): a field list in
`TestGenerateCA_RespectsOptions` and a literal in
`TestValidateServerConfig_PortConflict`. Applied `gofmt -w` to
internal/pki/manager_test.go and internal/storage/config_test.go, which is 16
lines and no behaviour change.

The step runs before `npm ci`: `gofmt -l` walks the tree, and node_modules has
no business being in that walk. On failure it prints the offending files and the
diff, so the fix is `gofmt -w` on exactly what it names.

One trap worth writing down, because it cost time here: running `gofmt -l`
locally on Windows flags extra files that CI reports clean. The working copy is
CRLF (core.autocrlf) while gofmt expects LF, so whole files come back as
"unformatted". The repository stores LF via .gitattributes, which is what the
runner checks out — so trust CI over a local Windows run, or verify with a
checkout made with core.autocrlf=false, which is how the two real deviations
above were told apart from the four false ones.
@Wasabules
Wasabules merged commit a45d61e into main Sep 6, 2026
9 checks passed
@Wasabules
Wasabules deleted the ci-gofmt branch September 6, 2026 17:57
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