Chunk
Overview
Chunk splits into sub-slices of size (lodash chunk).
If you are coming from Node.js, the closest pattern is _.chunk(arr, n).
Signature
go
func Chunk[T any](in []T, size int) [][]TCompare: Node.js · Standard Go · gox
js
_.chunk(arr, n)go
// Manual loop or Go 1.21+ slices package
for _, v := range items {
// transform or filter v
}go
import "github.com/sahilkhaire/gox/slice"
slice.Chunk(arr, n)Example
go
import "github.com/sahilkhaire/gox/slice"
slice.Chunk(arr, n)Tips
Chain Filter, Map, and Reduce for lodash-style pipelines. Results are new slices — inputs are never mutated.
Standard library alternative
Use a for loop or Go 1.21+ slices package helpers from the standard library.