MCPcopy
hub / github.com/Terry-Mao/goim / SplitInt32s

Function SplitInt32s

pkg/strings/ints.go:41–55  ·  view source on GitHub ↗

SplitInt32s split string into int32 slice.

(s, p string)

Source from the content-addressed store, hash-verified

39
40// SplitInt32s split string into int32 slice.
41func SplitInt32s(s, p string) ([]int32, error) {
42 if s == "" {
43 return nil, nil
44 }
45 sArr := strings.Split(s, p)
46 res := make([]int32, 0, len(sArr))
47 for _, sc := range sArr {
48 i, err := strconv.ParseInt(sc, 10, 32)
49 if err != nil {
50 return nil, err
51 }
52 res = append(res, int32(i))
53 }
54 return res, nil
55}
56
57// JoinInt64s format int64 slice like:n1,n2,n3.
58func JoinInt64s(is []int64, p string) string {

Callers 2

OperateMethod · 0.92
TestInt32Function · 0.85

Calls

no outgoing calls

Tested by 1

TestInt32Function · 0.68