JoinInt64s format int64 slice like:n1,n2,n3.
(is []int64, p string)
| 56 | |
| 57 | // JoinInt64s format int64 slice like:n1,n2,n3. |
| 58 | func JoinInt64s(is []int64, p string) string { |
| 59 | if len(is) == 0 { |
| 60 | return "" |
| 61 | } |
| 62 | if len(is) == 1 { |
| 63 | return strconv.FormatInt(is[0], 10) |
| 64 | } |
| 65 | buf := bfPool.Get().(*bytes.Buffer) |
| 66 | for _, i := range is { |
| 67 | buf.WriteString(strconv.FormatInt(i, 10)) |
| 68 | buf.WriteString(p) |
| 69 | } |
| 70 | if buf.Len() > 0 { |
| 71 | buf.Truncate(buf.Len() - 1) |
| 72 | } |
| 73 | s := buf.String() |
| 74 | buf.Reset() |
| 75 | bfPool.Put(buf) |
| 76 | return s |
| 77 | } |
| 78 | |
| 79 | // SplitInt64s split string into int64 slice. |
| 80 | func SplitInt64s(s, p string) ([]int64, error) { |