Documentation ¶
Index ¶
- func Assign[K comparable, V any](maps ...map[K]V) map[K]V
- func CopyFS(dest wfs.WriteFileFS, src fs.FS, root string) error
- func Filter[T any](collection []T, callback func(item T, index int) bool) []T
- func FilterErr[T any](collection []T, callback func(item T, index int) (bool, error)) ([]T, error)
- func FilterMap[T any, R any](collection []T, callback func(item T, index int) (R, bool)) []R
- func FilterMapErr[T any, R any](collection []T, callback func(item T, index int) (R, bool, error)) ([]R, error)
- func Flatten[T any](lists ...[]T) []T
- func Keys[K comparable, V any](m map[K]V) []K
- func Map[T any, R any](collection []T, callback func(item T, index int) R) []R
- func MapErr[T any, R any](collection []T, callback func(item T, index int) (R, error)) ([]R, error)
- func MapFromSlice[T any, K comparable, V any](collection []T, callback func(item T, index int) (K, V)) map[K]V
- func MapFromSliceErr[T any, K comparable, V any](collection []T, callback func(item T, index int) (K, V, error)) (map[K]V, error)
- func Must[T any](out T, err error) T
- func Ptr[T any](x T) *T
- func ToAnySlice[T any](collection []T) []any
- func Values[K comparable, V any](m map[K]V) []V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Assign ¶
func Assign[K comparable, V any](maps ...map[K]V) map[K]V
Assign merges multiple maps from left to right.
func FilterErr ¶
FilterErr is like Filter, but the callback function can fail. In such a case, a nil slice and the error from the callback is returned. This function fails fast; i.e it stops iteration at the first non-nil error
func FilterMap ¶
FilterMap is the combination of Filter & Map, returning the elements from the input slice as transformed by the callback function, but only in cases where the callback function also returns true
func FilterMapErr ¶
func FilterMapErr[T any, R any](collection []T, callback func(item T, index int) (R, bool, error)) ([]R, error)
FilterMapErr is like FilterMap, but the callback function can fail. In such a case, a nil slice and the error from the callback is returned. This function fails fast; i.e it stops iteration at the first non-nil error
func Flatten ¶
func Flatten[T any](lists ...[]T) []T
Flatten consolidates multiple lists into a single conjoined list
func Map ¶
Map returns all elements of the input slice as transformed by the supplied callback function
func MapErr ¶
MapErr is like Map, but the callback function can fail. In such a case, a nil slice and error from the callback is returned. This function fails fast; i.e it stops iteration at the first non-nil error
func MapFromSlice ¶
func MapFromSlice[T any, K comparable, V any](collection []T, callback func(item T, index int) (K, V)) map[K]V
MapFromSlice returns a map, whose keys & values are the return values from applying the callback function to each element of the given slice
func MapFromSliceErr ¶
func MapFromSliceErr[T any, K comparable, V any](collection []T, callback func(item T, index int) (K, V, error)) (map[K]V, error)
MapFromSliceErr is like MapFromSlice, but the callback function can fail. In such a case, a nil slice and the error from the callback is returned. This function fails fast; i.e it stops iteration at the first non-nil error
func Must ¶
Must wraps a function call that returns value and error, and panics if the error is non-nil
func ToAnySlice ¶
ToAnySlice returns a new slice where all elements of `collection` are mapped to the `any` type
func Values ¶
func Values[K comparable, V any](m map[K]V) []V
Values creates an slice of the map values.
Types ¶
This section is empty.