refactor: remove direct pflag import from tracing.go#6914
Merged
Conversation
3 tasks
Change registerTracingFlags to accept *cobra.Command instead of *pflag.FlagSet. The function now calls cmd.Flags() internally, removing the only direct github.com/spf13/pflag import from tracing.go and aligning with all other flag registration helpers in the package. Addresses go-fan recommendation from issue #<issue>.
Copilot
AI
changed the title
[WIP] Review spf13/pflag Go module
refactor: remove direct pflag import from tracing.go
Jun 2, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors tracing flag registration in internal/cmd to align with the package’s existing pattern of registering flags via *cobra.Command, eliminating the only direct pflag import in the package.
Changes:
- Refactor
registerTracingFlagsto accept*cobra.Commandand callcmd.Flags()internally. - Update the proxy command and tests to call
registerTracingFlags(cmd, ...)instead of passingcmd.Flags(). - Demote
github.com/spf13/pflagingo.modfrom a direct requirement to an indirect dependency (still pulled in viacobra).
Show a summary per file
| File | Description |
|---|---|
| internal/cmd/tracing.go | Updates registerTracingFlags signature to take *cobra.Command and removes direct pflag import. |
| internal/cmd/proxy.go | Updates tracing flag registration call site to pass the command instead of its FlagSet. |
| internal/cmd/tracing_helpers_test.go | Updates test call site to match the new registerTracingFlags signature. |
| internal/cmd/flags_tracing_test.go | Updates multiple test call sites to match the new registerTracingFlags signature. |
| go.mod | Moves spf13/pflag to indirect to reflect no direct imports in this module. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 5/5 changed files
- Comments generated: 0
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.
internal/cmd/tracing.gowas the only file in the package with a directgithub.com/spf13/pflagimport, solely becauseregisterTracingFlagsaccepted*pflag.FlagSetwhile every other flag-registration helper in the package accepts*cobra.Command.Changes
internal/cmd/tracing.go— changeregisterTracingFlagssignature from*pflag.FlagSet→*cobra.Command; callcmd.Flags()internally; droppflagimportinternal/cmd/proxy.go— update call site:registerTracingFlags(cmd.Flags(), …)→registerTracingFlags(cmd, …)internal/cmd/tracing_helpers_test.go,flags_tracing_test.go— update test call sites to match new signature