- With Type Input
package main
import (
"fmt"
"github.com/xbc30/godash"
)
func main() {
input := []int{1,2,3,4,5}
output := godash.ArrayIntChunk(input, 2)
fmt.Println(output) // [[1,2] [3,4] [5]]
}
- interface{} Input
package main
import (
"fmt"
"github.com/xbc30/godash"
)
func main() {
input := []int{1,2,3,4,5}
output := godash.ArrayChunk(godash.ArrayIntToInterface(input), 2)
fmt.Println(output) // [][]interface{}{{1, 2}, {3, 4}, {5}}
}
- Array
- String
- Map
-
Unit Test
- Single Func Test
go test -v -run="TestArrayIntChunk" -count 1
- File Test
go test -v -run="" -count 1
-
Benchmark Test
go test --bench=. array_test.go array.go -benchmem