fix cast.ToUint64 12344423419941918335 return 0

This commit is contained in:
lr123liurui 2023-03-06 20:49:50 +08:00
parent ba0a5b63c8
commit 855218d797
1 changed files with 2 additions and 2 deletions

View File

@ -598,12 +598,12 @@ func ToUint64E(i interface{}) (uint64, error) {
switch s := i.(type) { switch s := i.(type) {
case string: case string:
v, err := strconv.ParseInt(trimZeroDecimal(s), 0, 0) v, err := strconv.ParseUint(trimZeroDecimal(s), 0, 0)
if err == nil { if err == nil {
if v < 0 { if v < 0 {
return 0, errNegativeNotAllowed return 0, errNegativeNotAllowed
} }
return uint64(v), nil return v, nil
} }
return 0, fmt.Errorf("unable to cast %#v of type %T to uint64", i, i) return 0, fmt.Errorf("unable to cast %#v of type %T to uint64", i, i)
case json.Number: case json.Number: