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)
- Host: GitHub
- URL: https://github.com/kirito41dd/xslice
- Owner: kirito41dd
- License: mit
- Created: 2021-07-17T06:40:09.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-07-17T06:53:54.000Z (almost 4 years ago)
- Last Synced: 2025-02-11T10:24:33.827Z (3 months ago)
- Homepage:
- Size: 1.95 KB
- Stars: 4
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## usage
split a slice to some chunks, support []T which T can be any type.
```go
package mainimport (
"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]]
}
```