JoinInt32s format int32 slice like:n1,n2,n3.
(is []int32, p string)
| 17 | |
| 18 | // JoinInt32s format int32 slice like:n1,n2,n3. |
| 19 | func JoinInt32s(is []int32, p string) string { |
| 20 | if len(is) == 0 { |
| 21 | return "" |
| 22 | } |
| 23 | if len(is) == 1 { |
| 24 | return strconv.FormatInt(int64(is[0]), 10) |
| 25 | } |
| 26 | buf := bfPool.Get().(*bytes.Buffer) |
| 27 | for _, i := range is { |
| 28 | buf.WriteString(strconv.FormatInt(int64(i), 10)) |
| 29 | buf.WriteString(p) |
| 30 | } |
| 31 | if buf.Len() > 0 { |
| 32 | buf.Truncate(buf.Len() - 1) |
| 33 | } |
| 34 | s := buf.String() |
| 35 | buf.Reset() |
| 36 | bfPool.Put(buf) |
| 37 | return s |
| 38 | } |
| 39 | |
| 40 | // SplitInt32s split string into int32 slice. |
| 41 | func SplitInt32s(s, p string) ([]int32, error) { |