version: centralize banner through flags.Banner()#14
Merged
Conversation
Before this, 26 tools hardcoded the literal "gopacket vX.Y.Z-beta - Copyright 2026 Google LLC" banner in print statements, totaling 34 occurrences across the tree. Every version bump meant updating the same string 34 times. Switches every tool to call flags.Banner(), which builds the banner from flags.Version. The Version const in pkg/flags/flags.go is now the single source of truth; future version bumps are a one-line change. Mechanical split: - 3 common print patterns (fmt.Println, fmt.Fprintln os.Stderr, fmt.Fprintf with trailing \n\n) swept with sed. - 6 heredoc-style flag.Usage functions had the banner line on a backtick-quoted format string. Each was split into a separate fmt.Fprintln(os.Stderr, flags.Banner()) followed by the existing Fprintf with the banner line trimmed off the format string. - 9 tools needed a new pkg/flags import added. - tools/describeTicket already imports github.com/jcmturner/gokrb5 /v8/iana/flags for Kerberos flag constants, so pkg/flags is aliased as gopflags there to avoid the name collision. Verified: go build, go vet, and go test ./pkg/transport/ all clean under default, CGO_ENABLED=0, and GOOS=windows CGO_ENABLED=0. Spot- checked -h output on samrdump, rpcmap, mssqlinstance, ping, and describeTicket; each renders the banner identically to before.
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
26 tools hardcoded the literal
gopacket vX.Y.Z-beta - Copyright 2026 Google LLCbanner in print statements, totaling 34 occurrences across the tree. Every version bump meant updating the same string 34 times in 27 files (26 tools pluspkg/flags/flags.go).Switches every tool to call
flags.Banner(), which builds the banner fromflags.Version. TheVersionconst inpkg/flags/flags.gois now the single source of truth; future bumps are a one-line change.Mechanical split
Three common print patterns (
fmt.Println,fmt.Fprintln(os.Stderr, ...),fmt.Fprintf(os.Stderr, "...\n\n")) were swept withsed.Six heredoc-style
flag.Usagefunctions had the banner line on a backtick-quoted format string. Each was split into a separatefmt.Fprintln(os.Stderr, flags.Banner())followed by the existingFprintfwith the banner line trimmed off the format string. Output is byte-identical.Nine tools needed a new
pkg/flagsimport added:describeTicket,getArch,ntfs-read,ping,ping6,sniff,sniffer,split,ticketer.tools/describeTicketalready importsgithub.com/jcmturner/gokrb5/v8/iana/flagsfor Kerberos flag constants (used in 14 places), sopkg/flagsis aliased asgopflagsthere to avoid the name collision.Test plan
go build ./...clean (default, cgo=1 Linux)CGO_ENABLED=0 go build ./...cleanGOOS=windows CGO_ENABLED=0 go build ./...cleango vet ./...clean across all three configurationsgo test ./pkg/transport/passes, 13/13-houtput on samrdump (Println pattern), rpcmap (heredoc), mssqlinstance (heredoc with Fprintf), ping (Fprintf with\n\n), and describeTicket (aliased import). Every tool renders the banner identically to before.