From 3d311b65326da26c3ba237f0e795e8513ed73b52 Mon Sep 17 00:00:00 2001 From: Danilo Pantani Date: Thu, 18 Jul 2024 21:37:37 +0200 Subject: [PATCH] cast results from exportToFlagValue function --- hermes/cmd/flag.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hermes/cmd/flag.go b/hermes/cmd/flag.go index da2ef922..cbad9e80 100644 --- a/hermes/cmd/flag.go +++ b/hermes/cmd/flag.go @@ -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 } @@ -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: