3
0

Ensure CastToFloat gets untyped value

This commit is contained in:
Denis Arh
2021-04-03 08:26:17 +02:00
parent c391af0bb9
commit 99d5f75419
+8
View File
@@ -339,6 +339,14 @@ func CastToDateTime(val interface{}) (out *time.Time, err error) {
}
func CastToFloat(val interface{}) (out float64, err error) {
val = UntypedValue(val)
switch val := val.(type) {
case nil:
return 0, nil
case *Float:
return val.value, nil
}
return cast.ToFloat64E(emptyStringFailsafe(val))
}