cast
cast copied to clipboard
cast.ToInt("08") return 0 and so on
`package main
import ( "fmt" "strconv"
"github.com/spf13/cast"
)
func main() {
for i := 0; i <= 20; i++{
fmt.Println(cast.ToInt(fmt.Sprintf("0%d",i)))
}
fmt.Println("-------------------")
for i := 0; i <= 20; i++{
nums, _ := strconv.Atoi(fmt.Sprintf("0%d",i))
fmt.Println(nums)
}
}`
result: 0 1 2 3 4 5 6 7 0 0 8 9 10 11 12 13 14 15 0 0 16
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
same reason as #216
same problem