Skip to content

Commit

Permalink
use proper unsigned int conv from string
Browse files Browse the repository at this point in the history
  • Loading branch information
dhubler committed Feb 11, 2024
1 parent 102c16d commit 18f19d6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions val/conv.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ func toInt32(val interface{}) (n int32, err error) {
case int64:
return int32(x), nil
case string:
i, err := strconv.ParseUint(x, 10, 32)
i, err := strconv.ParseInt(x, 10, 32)
return int32(i), err
case float64:
return int32(x), nil
Expand Down Expand Up @@ -508,7 +508,7 @@ func toUInt32(val interface{}) (uint32, error) {
return x, nil
default:
i, err := toUInt64(val)
if err == nil && i >= 0 && i <= math.MaxUint32 {
if err == nil && i <= math.MaxUint32 {
return uint32(i), nil
}
}
Expand Down Expand Up @@ -678,7 +678,7 @@ func toUInt64(val interface{}) (uint64, error) {
case uint64:
return x, nil
case string:
i, err := strconv.ParseInt(x, 10, 64)
i, err := strconv.ParseUint(x, 10, 64)
return uint64(i), err
case float64:
return uint64(x), nil
Expand Down

0 comments on commit 18f19d6

Please sign in to comment.