Skip to content

fixes expected cast.ToInt behavior with prefixed "0" in string #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions caste.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func ToInt64E(i interface{}) (int64, error) {
case float32:
return int64(s), nil
case string:
v, err := strconv.ParseInt(s, 0, 0)
v, err := strconv.ParseInt(s, 10, 0)
if err == nil {
return v, nil
}
Expand Down Expand Up @@ -258,7 +258,7 @@ func ToInt32E(i interface{}) (int32, error) {
case float32:
return int32(s), nil
case string:
v, err := strconv.ParseInt(s, 0, 0)
v, err := strconv.ParseInt(s, 10, 0)
if err == nil {
return int32(v), nil
}
Expand Down Expand Up @@ -305,7 +305,7 @@ func ToInt16E(i interface{}) (int16, error) {
case float32:
return int16(s), nil
case string:
v, err := strconv.ParseInt(s, 0, 0)
v, err := strconv.ParseInt(s, 10, 0)
if err == nil {
return int16(v), nil
}
Expand Down Expand Up @@ -352,7 +352,7 @@ func ToInt8E(i interface{}) (int8, error) {
case float32:
return int8(s), nil
case string:
v, err := strconv.ParseInt(s, 0, 0)
v, err := strconv.ParseInt(s, 10, 0)
if err == nil {
return int8(v), nil
}
Expand Down Expand Up @@ -399,7 +399,7 @@ func ToIntE(i interface{}) (int, error) {
case float32:
return int(s), nil
case string:
v, err := strconv.ParseInt(s, 0, 0)
v, err := strconv.ParseInt(s, 10, 0)
if err == nil {
return int(v), nil
}
Expand All @@ -422,7 +422,7 @@ func ToUintE(i interface{}) (uint, error) {

switch s := i.(type) {
case string:
v, err := strconv.ParseUint(s, 0, 0)
v, err := strconv.ParseUint(s, 10, 0)
if err == nil {
return uint(v), nil
}
Expand Down Expand Up @@ -490,7 +490,7 @@ func ToUint64E(i interface{}) (uint64, error) {

switch s := i.(type) {
case string:
v, err := strconv.ParseUint(s, 0, 64)
v, err := strconv.ParseUint(s, 10, 64)
if err == nil {
return v, nil
}
Expand Down Expand Up @@ -558,7 +558,7 @@ func ToUint32E(i interface{}) (uint32, error) {

switch s := i.(type) {
case string:
v, err := strconv.ParseUint(s, 0, 32)
v, err := strconv.ParseUint(s, 10, 32)
if err == nil {
return uint32(v), nil
}
Expand Down Expand Up @@ -626,7 +626,7 @@ func ToUint16E(i interface{}) (uint16, error) {

switch s := i.(type) {
case string:
v, err := strconv.ParseUint(s, 0, 16)
v, err := strconv.ParseUint(s, 10, 16)
if err == nil {
return uint16(v), nil
}
Expand Down Expand Up @@ -694,7 +694,7 @@ func ToUint8E(i interface{}) (uint8, error) {

switch s := i.(type) {
case string:
v, err := strconv.ParseUint(s, 0, 8)
v, err := strconv.ParseUint(s, 10, 8)
if err == nil {
return uint8(v), nil
}
Expand Down