diff --git a/set.go b/set.go index f1ab15f675802831017357354d552dd19d72cefd..f5ca2f43314c861ad15eeb3abcf15d50c3463f31 100644 --- a/set.go +++ b/set.go @@ -89,7 +89,7 @@ func SetValue[D any](obj D, keyWithDots string, newValue any) error { if newValueKind == reflect.Int { v.SetInt(int64(newValue.(int))) } else { - s, err := strconv.ParseInt(newValue.(string), 10, 64) + s, err := strconv.ParseInt(fmt.Sprintf("%v", newValue), 10, 64) if err != nil { return err } @@ -101,7 +101,7 @@ func SetValue[D any](obj D, keyWithDots string, newValue any) error { if newValueKind == reflect.Int { v.SetUint(uint64(newValue.(int))) } else { - s, err := strconv.ParseInt(newValue.(string), 10, 64) + s, err := strconv.ParseInt(fmt.Sprintf("%v", newValue), 10, 64) if err != nil { return err } @@ -113,7 +113,7 @@ func SetValue[D any](obj D, keyWithDots string, newValue any) error { if newValueKind == reflect.Bool { v.SetBool(newValue.(bool)) } else { - b, err := strconv.ParseBool(newValue.(string)) + b, err := strconv.ParseBool(fmt.Sprintf("%v", newValue)) if err != nil { return err } @@ -126,7 +126,7 @@ func SetValue[D any](obj D, keyWithDots string, newValue any) error { if newValueKind == reflect.Float64 { v.SetFloat(newValue.(float64)) } else { - s, err := strconv.ParseFloat(newValue.(string), 64) + s, err := strconv.ParseFloat(fmt.Sprintf("%v", newValue), 64) if err != nil { return err }