Skip to content

Commit

Permalink
add SliceStringToInt
Browse files Browse the repository at this point in the history
  • Loading branch information
iikira committed Aug 1, 2018
1 parent 7000d81 commit f97b4d2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pcsutil/converter/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,23 @@ func SliceStringToInt64(ss []string) (si []int64) {
return
}

// SliceStringToInt []string 转换为 []int
func SliceStringToInt(ss []string) (si []int) {
si = make([]int, 0, len(ss))
var (
i int
err error
)
for k := range ss {
i, err = strconv.Atoi(ss[k])
if err != nil {
continue
}
si = append(si, i)
}
return
}

// MustInt 将string转换为int, 忽略错误
func MustInt(s string) (n int) {
n, _ = strconv.Atoi(s)
Expand Down

0 comments on commit f97b4d2

Please sign in to comment.