Skip to content

Commit

Permalink
remove redundant flag boolean option
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinfalting committed Jan 6, 2025
1 parent 8d329ed commit e143bd8
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions structconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func Parse(ctx context.Context, cfg any, optionFuncs ...optionFunc) error {
confhandler.EnvironmentVariable{}.Handle,
}

if opt.useFlags {
if opt.flagSet != nil {
flagHandler := confhandler.NewFlag(opt.flagSet)
if err := flagHandler.DefineFlags(fields); err != nil {
return err
Expand All @@ -52,8 +52,7 @@ func Parse(ctx context.Context, cfg any, optionFuncs ...optionFunc) error {
}

type option struct {
useFlags bool
flagSet *flag.FlagSet
flagSet *flag.FlagSet
}

type optionFunc func(opt *option)
Expand All @@ -63,7 +62,6 @@ type optionFunc func(opt *option)
// the stdlib flagset.
func WithFlagSet(fset *flag.FlagSet) optionFunc {
return func(opt *option) {
opt.useFlags = true
opt.flagSet = fset
}
}

0 comments on commit e143bd8

Please sign in to comment.