Skip to content

doc: name the pflag types the wrappers actually hold - #2166

Open
ump45nose wants to merge 1 commit into
spf13:masterfrom
ump45nose:doc-pflag-wrapper-types
Open

ump45nose wants to merge 1 commit into
spf13:masterfrom
ump45nose:doc-pflag-wrapper-types

Conversation

@ump45nose

Copy link
Copy Markdown

Overview:
Two comments in flags.go named pflag types that do not exist. pflagValueSet was described as "a wrapper around *pflag.ValueSet" while the struct holds *pflag.FlagSet (flags.go:23), and pflagValue as a wrapper around *pflag.flag while the field is flag *pflag.Flag (flags.go:36). Both comments now name the real types. Comment text only; no code changed.

What problem does it solve?:
There is no pflag.ValueSet in the pinned dependency — go.mod:12 requires github.com/spf13/pflag v1.0.10, which exports FlagSet, Flag, Value and SliceValue, and searching it for type ValueSet turns up nothing. The only way a caller obtains a pflagValueSet is through BindPFlags(flags *pflag.FlagSet) (viper.go:1087, viper.go:1091), which wraps the FlagSet, and VisitAll iterates it as p.flags.VisitAll(func(flag *pflag.Flag) …) (flags.go:27-31). So the comment points readers at a type they cannot find, one line above the type that is actually used.

Special notes:

  • gofmt is unaffected: line comments only, no struct tags or alignment touched.
  • I could not run go build ./..., go vet ./... or go test ./... — this environment's shell sandbox refused all toolchain commands, so CI is the first real run. The claim is settled statically by reading flags.go:20-37 against viper.go:1087-1092 and the vendored pflag v1.0.10.
  • AI assistance disclosure: an autonomous agent identified the stale type names, made the edit, and wrote this description on @ump45nose's behalf.

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