Repository navigation
gofmt the tree, and make staying formatted automatic - #4
Merged
Merged
Conversation
No behaviour change. One out-of-order import, and the //Comment -> // Comment spacing gofmt has wanted since Go 1.19, which accounts for all but one line of the diff. Kept apart from any substantive change so this never has to be read. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Formatting first, since that is what prompted this: gofmt before every commit, and keep a formatting sweep out of a behaviour change so the real diff stays readable. Also records the decisions from the test consolidation that are easy to undo by accident: the emulator tests must never be made skippable, every wait is a bounded assertion rather than a sleep, fixture setup belongs before startup and appends after, and there is one go.mod on purpose. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
CLAUDE.md asks for gofmt before every commit, but a written convention only works when someone remembers it. This makes it mechanical: after any Write/Edit/MultiEdit, .go files are formatted in place. Guards on the .go suffix so non-Go edits are untouched, and cannot fail a tool call - a missing path or a gofmt error is swallowed. Verified by piping the hook payload for a misformatted .go file (fixed), a .txt file (skipped), and an empty path (clean exit). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
main.gohad drifted out of gofmt compliance and nothing in the build fails over it, so it stayed that way silently. This formats it, writes down the convention, and then makes the convention mechanical so it does not depend on anyone remembering.1. The formatting sweep (
f846523)Only
main.gowas affected — 26 lines, no behaviour change:kingpinsorted aftergoogle.golang.org/api/option)//Comment→// Commentrule, which has applied since Go 1.19 and accounts for all but one line of the diffKept as its own commit so it never has to be read alongside a real change.
gofmt -l .now prints nothing.2.
CLAUDE.md(ce41922)The repo had no
CLAUDE.md. Formatting leads, since that is what prompted this: rungofmt -w .before every commit, and keep a formatting sweep out of a behaviour change so the substantive diff stays readable.It also records the decisions from #3 that are cheap to undo by accident and expensive to rediscover:
sleepread_from_beginningand tail-mode scenarios exist to testgo.modon purpose3. The gofmt hook (
963539e)A written convention only works when someone remembers it.
.claude/settings.jsonadds aPostToolUsehook so that after any Write/Edit/MultiEdit,.gofiles are formatted in place.Guards on the
.gosuffix, and cannot fail a tool call — a missing path or a gofmt error is swallowed.Verified by piping the exact stdin payload the hook receives:
.gofilefunc F( ) int→func F() int).txtfileThen verified end-to-end in a live session: a deliberate
func lineTimeAt(offset int)written through Edit came back correctly formatted, withgit diffempty.Note for reviewers: the hook does not take effect in a session that was already running when
.claude/settings.jsonfirst appeared — the settings watcher only monitors directories that had a settings file at startup. Open/hooksonce, or start a new session.Limits worth knowing
The hook only fires on Write/Edit/MultiEdit. A
.gofile produced by a script or agocommand will not trigger it, which is whyCLAUDE.mdstill asks for agofmt -l .check before committing rather than treating the hook as complete coverage.Verification
gofmt -l .empty,go build,go vet, andgo test ./...all clean — 30 tests, 42 subtests, 10 emulator scenarios.🤖 Generated with Claude Code