Unexpected results with padded strings
Open
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 4k
- Forks
- 337
- Avg merge
- 15m
- Merged PRs (30d)
- 1
Description
https://play.golang.com/p/3oTZVLEkdas
package main
import (
"fmt"
"github.com/spf13/cast"
)
func main() {
x := cast.ToInt("08")
fmt.Printf("08 => %d\n", x)
x = cast.ToInt("8")
fmt.Printf("8 => %d\n", x)
}
I'd expect the result to be 8 in each scenario. However, "08" ends up hitting a path where the base is changed and the parsing returns an error that we don't see.
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
Reproduce the reported behavior with the Go example from the linked playground, starting at cast.ToInt("08") and comparing it with cast.ToInt("8"). Trace the string parsing path and verify that padded numeric strings return 8 without an unseen parsing error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100