Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Chunk ¶
func Chunk[K comparable](slice []K, batchSize int) [][]K
Chunk - create batches of an arbitrary typed slice into the given batch size
func PickField ¶
func PickField[K interface{}, V comparable](iterator []K, picker Picker[K, V]) []V
PickField - pick the value of a particular field from a slice into it's own slice using the given picker function
Types ¶
type Picker ¶ added in v0.1.0
type Picker[K interface{}, V comparable] func([]K) []V
func PickWithFunc ¶ added in v0.1.0
func PickWithFunc[K interface{}, V comparable](pickerFunc func(K) V) Picker[K, V]
PickWithFunc get the key using a picker function
exampleSlice := []pickFieldTestType{{value: "wake up"}, {value: "code"}, {value: "repeat"}} pickedSlices := slices.PickField(exampleSlice, slices.PickWithFunc( func(k pickFieldTestType) string { return k.value }, ))
func PickWithKey ¶ added in v0.1.0
PickWithKey when working with a single field, you can use this picker to get the values from the passed generic type.
exampleSlice := []pickFieldTestType{{value: "wake up"}, {value: "code"}, {value: "repeat"}} pickedSlices := slices.PickField(exampleSlice, slices.PickWithKey[pickFieldTestType]("value"), )
Click to show internal directories.
Click to hide internal directories.