Documentation
¶
Index ¶
- func All[A any](src []A, pred func(A) bool) bool
- func Any[A any](src []A, pred func(A) bool) bool
- func CloseIgnore(c io.Closer)
- func CloseIgnoreCtx(ctx context.Context, close func(ctx context.Context) error)
- func Delete[T comparable](slice []T, t T) ([]T, bool)
- func Filter[Elem any](src []Elem, fn func(Elem) bool) []Elem
- func Find[A any](src []A, pred func(A) bool) (A, bool)
- func FlatMap[A, B any](src []A, fn func(A) []B) []B
- func Map[A, B any](src []A, fn func(A) B) []B
- func MapAndFilter[A, B any](src []A, fn func(A) (B, bool)) []B
- func MapErr[A, B any](src []A, fn func(A) (B, error)) ([]B, error)
- func MapKeys[M ~map[K]V, K comparable, V any](m M) []K
- func Max[A any, B cmp.Ordered](src []A, fn func(A) B) B
- func MergeMaps[K comparable, V any](ms ...map[K]V) map[K]V
- func ToMap[K comparable, V any](src []V, key func(V) K) map[K]V
- func TransformMapKeys[K1, K2 comparable, V any](m map[K1]V, fn func(K1) K2) map[K2]V
- func TransformMapToSlice[K comparable, V any, R any](m map[K]V, fn func(K, V) R) []R
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloseIgnore ¶ added in v1.25.0
CloseIgnore closes c, ignoring any error. Its main use is to satisfy linters.
func CloseIgnoreCtx ¶ added in v1.50.1
func Delete ¶ added in v1.42.1
func Delete[T comparable](slice []T, t T) ([]T, bool)
func Filter ¶
Filter applies fn on all elements in src, producing a new slice containing the elements for which fn returned true, preserving the same order.
func Find ¶ added in v1.33.0
Find returns the first element where pred returns true. The second argument is true if an element was found.
func FlatMap ¶ added in v1.35.3
func FlatMap[A, B any](src []A, fn func(A) []B) []B
FlatMap applies fn on all elements in src, producing a new slice with the results, in order.
func Map ¶
func Map[A, B any](src []A, fn func(A) B) []B
Map applies fn on all elements in src, producing a new slice with the results, in order.
func MapAndFilter ¶ added in v1.35.3
func MapAndFilter[A, B any](src []A, fn func(A) (B,