spf13 / spf13/cast

cast.ToInt("08") return 0 and so on

Open
#214 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
4k
Forks
337
Avg merge
15m
Merged PRs (30d)
1

Description

`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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported conversions from the Go example and inspect the cast.ToInt entry point and its handling of numeric strings. Compare its results with strconv.Atoi for values such as "08", "017", and "018"; done means the cast behavior matches the demonstrated standard-library results, with regression coverage for the affected inputs.

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
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.