toInt/toInt64 is wrong
Open
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 4k
- Forks
- 337
- Avg merge
- 15m
- Merged PRs (30d)
- 1
Description
var value = "00100"
fmt.Println(strconv.ParseInt(value, 10, 64))
fmt.Println(strconv.Atoi(value))
fmt.Println(cast.ToInt64E(value))
fmt.Println(cast.ToIntE(value))
output
100 <nil> ✅
100 <nil> ✅
64 <nil> ❌
64 <nil> ❌
var value = "012345678"
fmt.Println(strconv.ParseInt(value, 10, 64))
fmt.Println(strconv.Atoi(value))
fmt.Println(cast.ToInt64E(value))
fmt.Println(cast.ToIntE(value))
output
12345678 <nil> ✅
12345678 <nil> ✅
0 unable to cast "012345678" of type string to int64 ❌
0 unable to cast "012345678" of type string to int ❌
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the cast.ToInt64E and cast.ToIntE entry points and compare their handling of the shown decimal strings with strconv.ParseInt and strconv.Atoi. Done means values such as "00100" and "012345678" convert to 100 and 12345678 without errors, with tests covering these examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100