Skip to content

refactor: remove direct pflag import from tracing.go#6914

Merged
lpcox merged 2 commits into
mainfrom
copilot/go-fan-review-spf13-pflag
Jun 2, 2026
Merged

refactor: remove direct pflag import from tracing.go#6914
lpcox merged 2 commits into
mainfrom
copilot/go-fan-review-spf13-pflag

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 2, 2026

internal/cmd/tracing.go was the only file in the package with a direct github.com/spf13/pflag import, solely because registerTracingFlags accepted *pflag.FlagSet while every other flag-registration helper in the package accepts *cobra.Command.

Changes

  • internal/cmd/tracing.go — change registerTracingFlags signature from *pflag.FlagSet*cobra.Command; call cmd.Flags() internally; drop pflag import
  • internal/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
// Before
func registerTracingFlags(flags *pflag.FlagSet, ...) {
    flags.StringVar(...)
}
// Called as: registerTracingFlags(cmd.Flags(), &otlpEndpoint, ...)

// After — no pflag import needed
func registerTracingFlags(cmd *cobra.Command, ...) {
    flags := cmd.Flags()
    flags.StringVar(...)
}
// Called as: registerTracingFlags(cmd, &otlpEndpoint, ...)

Copilot AI linked an issue Jun 2, 2026 that may be closed by this pull request
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
Copilot AI requested a review from lpcox June 2, 2026 23:21
@lpcox lpcox marked this pull request as ready for review June 2, 2026 23:22
Copilot AI review requested due to automatic review settings June 2, 2026 23:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 registerTracingFlags to accept *cobra.Command and call cmd.Flags() internally.
  • Update the proxy command and tests to call registerTracingFlags(cmd, ...) instead of passing cmd.Flags().
  • Demote github.com/spf13/pflag in go.mod from a direct requirement to an indirect dependency (still pulled in via cobra).
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

Copilot finished work on behalf of lpcox June 2, 2026 23:24
@lpcox lpcox merged commit 69ad2c9 into main Jun 2, 2026
29 checks passed
@lpcox lpcox deleted the copilot/go-fan-review-spf13-pflag branch June 2, 2026 23:25
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.

[go-fan] Go Module Review: spf13/pflag

3 participants