An open API service indexing awesome lists of open source software.

https://github.com/kirito41dd/xslice

split a slice to some chunks in Go (use reflect)
https://github.com/kirito41dd/xslice

Last synced: about 1 month ago
JSON representation

split a slice to some chunks in Go (use reflect)

Awesome Lists containing this project

README

        

## usage
split a slice to some chunks, support []T which T can be any type.
```go
package main

import (
"fmt"
"github.com/kirito41dd/xslice"
)

func main() {
s := []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
i := xslice.SplitToChunks(s, 3)
ss := i.([][]int)
fmt.Println(ss) // [[0 1 2] [3 4 5] [6 7 8] [9]]
}
```