fns

package
v1.57.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2026 License: MPL-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All added in v1.42.1

func All[A any](src []A, pred func(A) bool) bool

All returns true if all elements in src satisfy the predicate.

func Any added in v1.35.3

func Any[A any](src []A, pred func(A) bool) bool

Any returns true if any element in src satisfies the predicate.

func CloseIgnore added in v1.25.0

func CloseIgnore(c io.Closer)

CloseIgnore closes c, ignoring any error. Its main use is to satisfy linters.

func CloseIgnoreCtx added in v1.50.1

func CloseIgnoreCtx(ctx context.Context, close func(ctx context.Context) error)

func Delete added in v1.42.1

func Delete[T comparable](slice []T, t T) ([]T, bool)

func Filter

func Filter[Elem any](src []Elem, fn func(Elem) bool) []Elem

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

func Find[A any](src []A, pred func(A) bool) (A, bool)

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,