mirror of https://github.com/spf13/cast.git
fix cast.ToUint64 12344423419941918335 return 0
This commit is contained in:
parent
ba0a5b63c8
commit
855218d797
4
caste.go
4
caste.go
|
@ -598,12 +598,12 @@ func ToUint64E(i interface{}) (uint64, error) {
|
|||
|
||||
switch s := i.(type) {
|
||||
case string:
|
||||
v, err := strconv.ParseInt(trimZeroDecimal(s), 0, 0)
|
||||
v, err := strconv.ParseUint(trimZeroDecimal(s), 0, 0)
|
||||
if err == nil {
|
||||
if v < 0 {
|
||||
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)
|
||||
case json.Number:
|
||||
|
|
Loading…
Reference in New Issue