chore: gofmt the tree + add a CI gofmt gate#1
Merged
Conversation
The fork was built and audited well (builds, vet-clean, all tests pass, works e2e against tshark 4.6) but 54 hand-edited files had drifted from gofmt — mostly import ordering and struct-field alignment. Run gofmt across the tree and add a format-check step to the Go CI workflow (it ran build/vet/test but not gofmt), so it stays clean. No logic change; build/vet/test still green.
- CI gate now excludes generated code (assets/statik, which statik does not emit gofmt-clean) and surfaces a gofmt parse error via '|| exit 1' instead of an empty stdout looking clean. Revert the generated statik.go to its generator output. - Two doc regressions the gofmt pass itself introduced: gofmt's doc-comment smart-quoting turned the vi '' (two single quotes) reference into a curly quote in pkg/app/marks.go, and it absorbed a //=== section banner into a func doc comment in ui/ui.go. Reword the marks.go docs to describe the command without the literal '' (which gofmt mangles even inside backticks), and detach the ui.go banner with a blank line so it stays a standalone separator. loader.go's corrected over-indent (flagged by a lane) is a whitespace- only fix; the loadPcapSync call sits correctly in the not-loading else branch before break Loop. Build/vet clean, all tests pass, gate green.
Round-2 panel: the gate excluded assets/statik but not the two pigeon-generated PEG parsers (pkg/streams/follow.go, pkg/shark/wiresharkcfg/parser.go), which would hit the same regen-fails-CI trap. All three carry the standard '// Code generated ... DO NOT EDIT.' marker, so key the exclusion on that marker instead of a path list — future-proof for any generated file. Also make the check space-safe (while/read) and surface a gofmt parse error per file rather than let empty stdout look clean (claude P3s). Revert the three generated files to their generator output so the diff only reformats hand-written code. Content edits that rode along (documented for transparency, since they aren't pure gofmt output): the marks.go doc reword and the ui.go banner detach from the previous round's fixes. gofmt is implicitly the CI's Go 1.22 toolchain, matching go.mod's declared version. Gate passes, build/vet clean, all tests pass.
Reviewer's GuideThis PR runs gofmt across the Go codebase and introduces a CI workflow step that enforces gofmt cleanliness for all tracked non-generated .go files. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
📝 WalkthroughWalkthroughThe PR adds CI enforcement for gofmt, persists the final conversation group, updates platform build constraints, and applies broad formatting, import-order, comment, and whitespace changes without altering existing APIs or most runtime behavior. ChangesFormatting enforcement and cleanup
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
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.
Summary
A small hygiene pass on the termshark fork. Unlike the other repos in this cleanup, the code and framing were already in good shape — the fork is honestly attributed (README "Original Project" section credits Graham Clark, LICENSE preserved, fork note in go.mod), builds clean,
go vetclean, all 27 test packages pass, and it works end to end (loads a pcap and parses packets via tshark 4.6.6). The only gap: gofmt.Changes
gofmt -lstep that fails on any unformatted file.Verification
go build ./...,go vet ./...clean.go test ./...: all packages pass, 0 failures (before and after gofmt).cmd/termshark, ran--pass-thru -r sample.pcap, confirmed real packets parsed via tshark 4.6.6.Summary by Sourcery
Apply gofmt formatting across the Go codebase and introduce a CI gate to enforce gofmt cleanliness on tracked .go files.
Enhancements:
CI:
Summary by cubic
Standardized Go formatting across the repo and added a CI
gofmtgate to keep it enforced. The gate skips files marked with the standard "Code generated ... DO NOT EDIT." header and fails on unformatted or parse-error files; no behavior changes.gofmtacross 54 files (import order/alignment only).gofmtcheck to.github/workflows/go.ymlthat ignores generated files by marker.pkg/pcap/loader.go); build, vet, and tests remain green.Written for commit 2f78501. Summary will update on new commits.
Summary by CodeRabbit