sing/common/buf/buffer.go
2022-01-29 03:25:38 +08:00

24 lines
383 B
Go

package buf
var Empty []byte
func init() {
Empty = make([]byte, 128)
}
func ForeachN(b []byte, size int) [][]byte {
total := len(b)
var index int
var retArr [][]byte
for {
nextIndex := index + size
if nextIndex < total {
retArr = append(retArr, b[index:nextIndex])
index = nextIndex
} else {
retArr = append(retArr, b[index:])
break
}
}
return retArr
}