Help us shape the future of Go! Take the 2026 Go Developer Survey

lo

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Associate

func Associate[T any, K comparable, V any](collection []T, keyFn func(T) (K, V)) map[K]V

Associate converts a slice to a map by applying keyFn to each element.

func Contains

func Contains[T comparable](collection []T, v T) bool

Contains reports whether v is present in collection.

func ContainsBy

func ContainsBy[T any](collection []T, predicate func(T) bool) bool

ContainsBy reports whether any element of collection satisfies predicate.

func Find

func Find[T any](collection []T, predicate func(T) bool) (T, bool)

Find returns the first element satisfying predicate and true, or the zero value and false if no element matches.

func Keys

func Keys[K comparable, V any](m map[K]V) []K

Keys returns the keys of the map in an unspecified order.

func Must

func Must[T any](val T, err error) T

Must returns val and panics if err is non-nil.

func Ternary

func Ternary[T any](condition bool, ifTrue, ifFalse T) T

Ternary returns ifTrue when condition is true, otherwise ifFalse.

func Without

func Without[T comparable](collection []T, exclude ...T) []T

Without returns a copy of collection with all occurrences of exclude removed.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL