Skip to content

version: centralize banner through flags.Banner()#14

Merged
psycep merged 1 commit intomainfrom
version-centralize
Apr 22, 2026
Merged

version: centralize banner through flags.Banner()#14
psycep merged 1 commit intomainfrom
version-centralize

Conversation

@psycep
Copy link
Copy Markdown
Collaborator

@psycep psycep commented Apr 22, 2026

Summary

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 in 27 files (26 tools plus pkg/flags/flags.go).

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 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 with sed.

Six 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. Output is byte-identical.

Nine tools needed a new pkg/flags import added: describeTicket, getArch, ntfs-read, ping, ping6, sniff, sniffer, split, ticketer.

tools/describeTicket already imports github.com/jcmturner/gokrb5/v8/iana/flags for Kerberos flag constants (used in 14 places), so pkg/flags is aliased as gopflags there to avoid the name collision.

Test plan

  • go build ./... clean (default, cgo=1 Linux)
  • CGO_ENABLED=0 go build ./... clean
  • GOOS=windows CGO_ENABLED=0 go build ./... clean
  • go vet ./... clean across all three configurations
  • go test ./pkg/transport/ passes, 13/13
  • Spot-checked -h output 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.

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.
@psycep psycep merged commit a0afb8d into main Apr 22, 2026
2 checks passed
@psycep psycep deleted the version-centralize branch April 22, 2026 18:33
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