Skip to content

Commit

Permalink
cast results from exportToFlagValue function
Browse files Browse the repository at this point in the history
  • Loading branch information
Pantani committed Jul 18, 2024
1 parent e5b9dc9 commit 3d311b6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions hermes/cmd/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func getFlag[A any](flags []*plugin.Flag, key string) (result A, err error) {

value, ok := v.(A)
if !ok {
return result, errors.Wrapf(ErrFlagAssertion, "type assertion to %T failed", v)
return result, errors.Wrapf(ErrFlagAssertion, "type assertion to %T failed for field %s", v, key)
}
return value, nil
}
Expand All @@ -136,25 +136,25 @@ func exportToFlagValue(f *plugin.Flag) (interface{}, error) {
case plugin.FlagTypeInt:
v, err := strconv.Atoi(flagValue(f))
if err != nil {
return 0, err
return int(0), err
}
return v, nil
case plugin.FlagTypeUint:
v, err := strconv.ParseUint(flagValue(f), 10, 64)
if err != nil {
return 0, err
return uint(0), err
}
return v, nil
case plugin.FlagTypeInt64:
v, err := strconv.ParseInt(flagValue(f), 10, 64)
if err != nil {
return 0, err
return int64(0), err
}
return v, nil
case plugin.FlagTypeUint64:
v, err := strconv.ParseUint(flagValue(f), 10, 64)
if err != nil {
return 0, err
return uint64(0), err
}
return v, nil
case plugin.FlagTypeStringSlice:
Expand Down

0 comments on commit 3d311b6

Please sign in to comment.