From ba6d74067d8a38f3d2853daf80805699d7b34e43 Mon Sep 17 00:00:00 2001 From: Sergio Salvatore Date: Fri, 30 Aug 2024 11:01:07 -0400 Subject: [PATCH] Remove Unnecessary Error from pflag Pflag has types for all the integer sizes so we don't need to check for overflowing and thus this code that was inherited from the flag package is unnecessary. --- sources/pflag/pflag.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/sources/pflag/pflag.go b/sources/pflag/pflag.go index 3d1b10c..3078062 100644 --- a/sources/pflag/pflag.go +++ b/sources/pflag/pflag.go @@ -445,8 +445,7 @@ func (s *Set) Value(_ context.Context, t *dials.Type) (reflect.Value, error) { return reflect.Value{}, err } } - var setErr error - val := reflect.New(t.Type()) + s.Flags.Visit(func(f *pflag.Flag) { fieldName, ok := s.flagFieldName[f.Name] if !ok { @@ -492,9 +491,6 @@ func (s *Set) Value(_ context.Context, t *dials.Type) (reflect.Value, error) { ffield.Set(cfval) } }) - if setErr != nil { - return val.Elem(), setErr - } return s.tfmr.ReverseTranslate(s.trnslVal) }