Documentation
¶
Index ¶
- Variables
- func Assign[K comparable, V any, Map ~map[K]V](maps ...Map) Map
- func Associate[T any, K comparable, V any](collection []T, transform func(item T) (K, V)) map[K]V
- func Async[A any](f func() A) <-chan A
- func Async0(f func()) <-chan struct{}
- func Async1[A any](f func() A) <-chan A
- func Async2[A, B any](f func() (A, B)) <-chan Tuple2[A, B]
- func Async3[A, B, C any](f func() (A, B, C)) <-chan Tuple3[A, B, C]
- func Async4[A, B, C, D any](f func() (A, B, C, D)) <-chan Tuple4[A, B, C, D]
- func Async5[A, B, C, D, E any](f func() (A, B, C, D, E)) <-chan Tuple5[A, B, C, D, E]
- func Async6[A, B, C, D, E, F any](f func() (A, B, C, D, E, F)) <-chan Tuple6[A, B, C, D, E, F]
- func Attempt(maxIteration int, f func(index int) error) (int, error)
- func AttemptWhile(maxIteration int, f func(int) (error, bool)) (int, error)
- func AttemptWhileWithDelay(maxIteration int, delay time.Duration, ...) (int, time.Duration, error)
- func AttemptWithDelay(maxIteration int, delay time.Duration, ...) (int, time.Duration, error)
- func Batch[T any](ch <-chan T, size int) (collection []T, length int, readTime time.Duration, ok bool)deprecated
- func BatchWithTimeout[T any](ch <-chan T, size int, timeout time.Duration) (collection []T, length int, readTime time.Duration, ok bool)deprecated
- func Buffer[T any](ch <-chan T, size int) (collection []T, length int, readTime time.Duration, ok bool)
- func BufferWithContext[T any](ctx context.Context, ch <-chan T, size int) (collection []T, length int, readTime time.Duration, ok bool)
- func BufferWithTimeout[T any](ch <-chan T, size int, timeout time.Duration) (collection []T, length int, readTime time.Duration, ok bool)
- func CamelCase(str string) string
- func Capitalize(str string) string
- func ChannelDispatcher[T any](stream <-chan T, count int, channelBufferCap int, ...) []<-chan T
- func ChannelMerge[T any](channelBufferCap int, upstreams ...<-chan T) <-chan Tdeprecated
- func ChannelToSlice[T any](ch <-chan T) []T
- func Chunk[T any, Slice ~[]T](collection Slice, size int) []Slice
- func ChunkEntries[K comparable, V any](m map[K]V, size int) []map[K]V
- func ChunkString[T ~string](str T, size int) []T
- func Clamp[T constraints.Ordered](value T, min T, max T) T
- func Coalesce[T comparable](values ...T) (result T, ok bool)
- func CoalesceMap[K comparable, V any](v ...map[K]V) (map[K]V, bool)
- func CoalesceMapOrEmpty[K comparable, V any](v ...map[K]V) map[K]V
- func CoalesceOrEmpty[T comparable](v ...T) T
- func CoalesceSlice[T any](v ...[]T) ([]T, bool)
- func CoalesceSliceOrEmpty[T any](v ...[]T) []T
- func Compact[T comparable, Slice ~[]T](collection Slice) Slice
- func Contains[T comparable](collection []T, element T) bool
- func ContainsBy[T any](collection []T, predicate func(item T) bool) bool
- func Count[T comparable](collection []T, value T) (count int)
- func CountBy[T any](collection []T, predicate func(item T) bool) (count int)
- func CountValues[T comparable](collection []T) map[T]int
- func CountValuesBy[T any, U comparable](collection []T, mapper func(item T) U) map[U]int
- func CrossJoinBy2[A, B, Out any](listA []A, listB []B, project func(a A, b B) Out) []Out
- func CrossJoinBy3[A, B, C, Out any](listA []A, listB []B, listC []C, project func(a A, b B, c C) Out) []Out
- func CrossJoinBy4[A, B, C, D, Out any](listA []A, listB []B, listC []C, listD []D, ...) []Out
- func CrossJoinBy5[A, B, C, D, E, Out any](listA []A, listB []B, listC []C, listD []D, listE []E, ...) []Out
- func CrossJoinBy6[A, B, C, D, E, F, Out any](listA []A, listB []B, listC []C, listD []D, listE []E, listF []F, ...) []Out
- func CrossJoinBy7[A, B, C, D, E, F, G, Out any](listA []A, listB []B, listC []C, listD []D, listE []E, listF []F, listG []G, ...) []Out
- func CrossJoinBy8[A, B, C, D, E, F, G, H, Out any](listA []A, listB []B, listC []C, listD []D, listE []E, listF []F, listG []G, ...) []Out
- func CrossJoinBy9[A, B, C, D, E, F, G, H, I, Out any](listA []A, listB []B, listC []C, listD []D, listE []E, listF []F, listG []G, ...) []Out
- func Difference[T comparable, Slice ~[]T](list1 Slice, list2 Slice) (Slice, Slice)
- func DispatchingStrategyFirst[T any](msg T, index uint64, channels []<-chan T) int
- func DispatchingStrategyLeast[T any](msg T, index uint64, channels []<-chan T) int
- func DispatchingStrategyMost[T any](msg T, index uint64, channels []<-chan T) int
- func DispatchingStrategyRandom[T any](msg T, index uint64, channels []<-chan T) int
- func DispatchingStrategyRoundRobin[T any](msg T, index uint64, channels []<-chan T) int
- func Drop[T any, Slice ~[]T](collection Slice, n int) Slice
- func DropByIndex[T any](collection []T, indexes ...int) []T
- func DropRight[T any, Slice ~[]T](collection Slice, n int) Slice
- func DropRightWhile[T any, Slice ~[]T](collection Slice, predicate func(item T) bool) Slice
- func DropWhile[T any, Slice ~[]T](collection Slice, predicate func(item T) bool) Slice
- func Duration(cb func()) time.Duration
- func Duration0(cb func()) time.Duration
- func Duration1[A any](cb func() A) (A, time.Duration)
- func Duration10[A, B, C, D, E, F, G, H, I, J any](cb func() (A, B, C, D, E, F, G, H, I, J)) (A, B, C, D, E, F, G, H, I, J, time.Duration)
- func Duration2[A, B any](cb func() (A, B)) (A, B, time.Duration)
- func Duration3[A, B, C any](cb func() (A, B, C)) (A, B, C, time.Duration)
- func Duration4[A, B, C, D any](cb func() (A, B, C, D)) (A, B, C, D, time.Duration)
- func Duration5[A, B, C, D, E any](cb func() (A, B, C, D, E)) (A, B, C, D, E, time.Duration)
- func Duration6[A, B, C, D, E, F any](cb func() (A, B, C, D, E, F)) (A, B, C, D, E, F, time.Duration)
- func Duration7[A, B, C, D, E, F, G any](cb func() (A, B, C, D, E, F, G)) (A, B, C, D, E, F, G, time.Duration)
- func Duration8[A, B, C, D, E, F, G, H any](cb func() (A, B, C, D, E, F, G, H)) (A, B, C, D, E, F, G, H, time.Duration)
- func Duration9[A, B, C, D, E, F, G, H, I any](cb func() (A, B, C, D, E, F, G, H, I)) (A, B, C, D, E, F, G, H, I, time.Duration)
- func Earliest(times ...time.Time) time.Time
- func EarliestBy[T any](collection []T, iteratee func(item T) time.Time) T
- func Elipse(str string, length int) stringdeprecated
- func Ellipsis(str string, length int) string
- func Empty[T any]() T
- func EmptyableToPtr[T any](x T) *T
- func ErrorsAs[T error](err error) (T, bool)
- func Every[T comparable](collection []T, subset []T) bool
- func EveryBy[T any](collection []T, predicate func(item T) bool) bool
- func FanIn[T any](channelBufferCap int, upstreams ...<-chan T) <-chan T
- func FanOut[T any](count int, channelsBufferCap int, upstream <-chan T) []<-chan T
- func Fill[T Clonable[T], Slice ~[]T](collection Slice, initial T) Slice
- func Filter[T any, Slice ~[]T](collection Slice, predicate func(item T, index int) bool) Slice
- func FilterMap[T any, R any](collection []T, callback func(item T, index int) (R, bool)) []R
- func FilterReject[T any, Slice ~[]T](collection Slice, predicate func(T, int) bool) (kept Slice, rejected Slice)
- func FilterSliceToMap[T any, K comparable, V any](collection []T, transform func(item T) (K, V, bool)) map[K]V
- func Find[T any](collection []T, predicate func(item T) bool) (T, bool)
- func FindDuplicates[T comparable, Slice ~[]T](collection Slice) Slice
- func FindDuplicatesBy[T any, U comparable, Slice ~[]T](collection Slice, iteratee func(item T) U) Slice
- func FindIndexOf[T any](collection []T, predicate func(item T) bool) (T, int, bool)
- func FindKey[K comparable, V comparable](object map[K]V, value V) (K, bool)
- func FindKeyBy[K comparable, V any](object map[K]V, predicate func(key K, value V) bool) (K, bool)
- func FindLastIndexOf[T any](collection []T, predicate func(item T) bool) (T, int, bool)
- func FindOrElse[T any](collection []T, fallback T, predicate func(item T) bool) T
- func FindUniques[T comparable, Slice ~[]T](collection Slice) Slice
- func FindUniquesBy[T any, U comparable, Slice ~[]T](collection Slice, iteratee func(item T) U) Slice
- func First[T any](collection []T) (T, bool)
- func FirstOr[T any](collection []T, fallback T) T
- func FirstOrEmpty[T any](collection []T) T
- func FlatMap[T any, R any](collection []T, iteratee func(item T, index int) []R) []R
- func Flatten[T any, Slice ~[]T](collection []Slice) Slice
- func ForEach[T any](collection []T, iteratee func(item T, index int))
- func ForEachWhile[T any](collection []T, iteratee func(item T, index int) (goon bool))
- func FromAnySlice[T any](in []any) (out []T, ok bool)
- func FromEntries[K comparable, V any](entries []Entry[K, V]) map[K]V
- func FromPairs[K comparable, V any](entries []Entry[K, V]) map[K]V
- func FromPtr[T any](x *T) T
- func FromPtrOr[T any](x *T, fallback T) T
- func FromSlicePtr[T any](collection []*T) []T
- func FromSlicePtrOr[T any](collection []*T, fallback T) []T
- func Generator[T any](bufferSize int, generator func(yield func(T))) <-chan T
- func GroupBy[T any, U comparable, Slice ~[]T](collection Slice, iteratee func(item T) U) map[U]Slice
- func HasKey[K comparable, V any](in map[K]V, key K) bool
- func If[T any](condition bool, result T) *ifElse[T]
- func IfF[T any](condition bool, resultF func() T) *ifElse[T]
- func IndexOf[T comparable](collection []T, element T) int
- func Interleave[T any, Slice ~[]T](collections ...Slice) Slice
- func Intersect[T comparable, Slice ~[]T](list1 Slice, list2 Slice) Slice
- func Invert[K comparable, V comparable](in map[K]V) map[V]K
- func IsEmpty[T comparable](v T) bool
- func IsNil(x any) bool
- func IsNotEmpty[T comparable](v T) bool
- func IsNotNil(x any) bool
- func IsSorted[T constraints.Ordered](collection []T) bool
- func IsSortedByKey[T any, K constraints.Ordered](collection []T, iteratee func(item T) K) bool
- func KebabCase(str string) string
- func KeyBy[K comparable, V any](collection []V, iteratee func(item V) K) map[K]V
- func Keyify[T comparable, Slice ~[]T](collection Slice) map[T]struct{}
- func Keys[K comparable, V any](in ...map[K]V) []K
- func Last[T any](collection []T) (T, bool)
- func LastIndexOf[T comparable](collection []T, element T) int
- func LastOr[T any](collection []T, fallback T) T
- func LastOrEmpty[T any](collection []T) T
- func Latest(times ...time.Time) time.Time
- func LatestBy[T any](collection []T, iteratee func(item T) time.Time) T
- func Map[T any, R any](collection []T, iteratee func(item T, index int) R) []R
- func MapEntries[K1 comparable, V1 any, K2 comparable, V2 any](in map[K1]V1, iteratee func(key K1, value V1) (K2, V2)) map[K2]V2
- func MapKeys[K comparable, V any, R comparable](in map[K]V, iteratee func(value V, key K) R) map[R]V
- func MapToSlice[K comparable, V any, R any](in map[K]V, iteratee func(key K, value V) R) []R
- func MapValues[K comparable, V any, R any](in map[K]V, iteratee func(value V, key K) R) map[K]R
- func Max[T constraints.Ordered](collection []T) T
- func MaxBy[T any](collection []T, comparison func(a T, b T) bool) T
- func MaxIndex[T constraints.Ordered](collection []T) (T, int)
- func MaxIndexBy[T any](collection []T, comparison func(a T, b T) bool) (T, int)
- func Mean[T constraints.Float | constraints.Integer](collection []T) T
- func MeanBy[T any, R constraints.Float | constraints.Integer](collection []T, iteratee func(item T) R) R
- func Min[T constraints.Ordered](collection []T) T
- func MinBy[T any](collection []T, comparison func(a T, b T) bool) T
- func MinIndex[T constraints.Ordered](collection []T) (T, int)
- func MinIndexBy[T any](collection []T, comparison func(a T, b T) bool) (T, int)
- func Must[T any](val T, err any, messageArgs ...any) T
- func Must0(err any, messageArgs ...any)
- func Must1[T any](val T, err any, messageArgs ...any) T
- func Must2[T1, T2 any](val1 T1, val2 T2, err any, messageArgs ...any) (T1, T2)
- func Must3[T1, T2, T3 any](val1 T1, val2 T2, val3 T3, err any, messageArgs ...any) (T1, T2, T3)
- func Must4[T1, T2, T3, T4 any](val1 T1, val2 T2, val3 T3, val4 T4, err any, messageArgs ...any) (T1, T2, T3, T4)
- func Must5[T1, T2, T3, T4, T5 any](val1 T1, val2 T2, val3 T3, val4 T4, val5 T5, err any, messageArgs ...any) (T1, T2, T3, T4, T5)
- func Must6[T1, T2, T3, T4, T5, T6 any](val1 T1, val2 T2, val3 T3, val4 T4, val5 T5, val6 T6, err any, ...) (T1, T2, T3, T4, T5, T6)
- func NewDebounce(duration time.Duration, f ...func()) (func(), func())
- func NewDebounceBy[T comparable](duration time.Duration, f ...func(key T, count int)) (func(key T), func(key T))
- func NewThrottle(interval time.Duration, f ...func()) (throttle func(), reset func())
- func NewThrottleBy[T comparable](interval time.Duration, f ...func(key T)) (throttle func(key T), reset func())
- func NewThrottleByWithCount[T comparable](interval time.Duration, count int, f ...func(key T)) (throttle func(key T), reset func())
- func NewThrottleWithCount(interval time.Duration, count int, f ...func()) (throttle func(), reset func())
- func Nil[T any]() *T
- func None[T comparable](collection []T, subset []T) bool
- func NoneBy[T any](collection []T, predicate func(item T) bool) bool
- func Nth[T any, N constraints.Integer](collection []T, nth N) (T, error)
- func OmitBy[K comparable, V any, Map ~map[K]V](in Map, predicate func(key K, value V) bool) Map
- func OmitByKeys[K comparable, V any, Map ~map[K]V](in Map, keys []K) Map
- func OmitByValues[K comparable, V comparable, Map ~map[K]V](in Map, values []V) Map
- func Partial[T1, T2, R any](f func(a T1, b T2) R, arg1 T1) func(T2) R
- func Partial1[T1, T2, R any](f func(T1, T2) R, arg1 T1) func(T2) R
- func Partial2[T1, T2, T3, R any](f func(T1, T2, T3) R, arg1 T1) func(T2, T3) R
- func Partial3[T1, T2, T3, T4, R any](f func(T1, T2, T3, T4) R, arg1 T1) func(T2, T3, T4) R
- func Partial4[T1, T2, T3, T4, T5, R any](f func(T1, T2, T3, T4, T5) R, arg1 T1) func(T2, T3, T4, T5) R
- func Partial5[T1, T2, T3, T4, T5, T6, R any](f func(T1, T2, T3, T4, T5, T6) R, arg1 T1) func(T2, T3, T4, T5, T6) R
- func PartitionBy[T any, K comparable, Slice ~[]T](collection Slice, iteratee func(item T) K) []Slice
- func PascalCase(str string) string
- func PickBy[K comparable, V any, Map ~map[K]V](in Map, predicate func(key K, value V) bool) Map
- func PickByKeys[K comparable, V any, Map ~map[K]V](in Map, keys []K) Map
- func PickByValues[K comparable, V comparable, Map ~map[K]V](in Map, values []V) Map
- func Product[T constraints.Float | constraints.Integer | constraints.Complex](collection []T) T
- func ProductBy[T any, R constraints.Float | constraints.Integer | constraints.Complex](collection []T, iteratee func(item T) R) R
- func RandomString(size int, charset []rune) string
- func Range(elementNum int) []int
- func RangeFrom[T constraints.Integer | constraints.Float](start T, elementNum int) []T
- func RangeWithSteps[T constraints.Integer | constraints.Float](start, end, step T) []T
- func Reduce[T any, R any](collection []T, accumulator func(agg R, item T, index int) R, initial R) R
- func ReduceRight[T any, R any](collection []T, accumulator func(agg R, item T, index int) R, initial R) R
- func Reject[T any, Slice ~[]T](collection Slice, predicate func(item T, index int) bool) Slice
- func RejectMap[T any, R any](collection []T, callback func(item T, index int) (R, bool)) []R
- func Repeat[T Clonable[T]](count int, initial T) []T
- func RepeatBy[T any](count int, predicate func(index int) T) []T
- func Replace[T comparable, Slice ~[]T](collection Slice, old T, new T, n int) Slice
- func ReplaceAll[T comparable, Slice ~[]T](collection Slice, old T, new T) Slice
- func Reverse[T any, Slice ~[]T](collection Slice) Slicedeprecated
- func RuneLength(str string) int
- func Sample[T any](collection []T) T
- func SampleBy[T any](collection []T, randomIntGenerator randomIntGenerator) T
- func Samples[T any, Slice ~[]T](collection Slice, count int) Slice
- func SamplesBy[T any, Slice ~[]T](collection Slice, count int, randomIntGenerator randomIntGenerator) Slice
- func Shuffle[T any, Slice ~[]T](collection Slice) Slicedeprecated
- func Slice[T any, Slice ~[]T](collection Slice, start int, end int) Slice
- func SliceToChannel[T any](bufferSize int, collection []T) <-chan T
- func SliceToMap[T any, K comparable, V any](collection []T, transform func(item T) (K, V)) map[K]V
- func SnakeCase(str string) string
- func Some[T comparable](collection []T, subset []T) bool
- func SomeBy[T any](collection []T, predicate func(item T) bool) bool
- func Splice[T any, Slice ~[]T](collection Slice, i int, elements ...T) Slice
- func Subset[T any, Slice ~[]T](collection Slice, offset int, length uint) Slice
- func Substring[T ~string](str T, offset int, length uint) T
- func Sum[T constraints.Float | constraints.Integer | constraints.Complex](collection []T) T
- func SumBy[T any, R constraints.Float | constraints.Integer | constraints.Complex](collection []T, iteratee func(item T) R) R
- func Switch[T comparable, R any](predicate T) *switchCase[T, R]
- func Synchronize(opt ...sync.Locker) *synchronize
- func Ternary[T any](condition bool, ifOutput T, elseOutput T) T
- func TernaryF[T any](condition bool, ifFunc func() T, elseFunc func() T) T
- func Times[T any](count int, iteratee func(index int) T) []T
- func ToAnySlice[T any](collection []T) []any
- func ToPtr[T any](x T) *T
- func ToSlicePtr[T any](collection []T) []*T
- func Try(callback func() error) (ok bool)
- func Try0(callback func()) bool
- func Try1(callback func() error) bool
- func Try2[T any](callback func() (T, error)) bool
- func Try3[T, R any](callback func() (T, R, error)) bool
- func Try4[T, R, S any](callback func() (T, R, S, error)) bool
- func Try5[T, R, S, Q any](callback func() (T, R, S, Q, error)) bool
- func Try6[T, R, S, Q, U any](callback func() (T, R, S, Q, U, error)) bool
- func TryCatch(callback func() error, catch func())
- func TryCatchWithErrorValue(callback func() error, catch func(any))
- func TryOr[A any](callback func() (A, error), fallbackA A) (A, bool)
- func TryOr1[A any](callback func() (A, error), fallbackA A) (A, bool)
- func TryOr2[A, B any](callback func() (A, B, error), fallbackA A, fallbackB B) (A, B, bool)
- func TryOr3[A, B, C any](callback func() (A, B, C, error), fallbackA A, fallbackB B, fallbackC C) (A, B, C, bool)
- func TryOr4[A, B, C, D any](callback func() (A, B, C, D, error), fallbackA A, fallbackB B, fallbackC C, ...) (A, B, C, D, bool)
- func TryOr5[A, B, C, D, E any](callback func() (A, B, C, D, E, error), fallbackA A, fallbackB B, fallbackC C, ...) (A, B, C, D, E, bool)
- func TryOr6[A, B, C, D, E, F any](callback func() (A, B, C, D, E, F, error), fallbackA A, fallbackB B, ...) (A, B, C, D, E, F, bool)
- func TryWithErrorValue(callback func() error) (errorValue any, ok bool)
- func Union[T comparable, Slice ~[]T](lists ...Slice) Slice
- func Uniq[T comparable, Slice ~[]T](collection Slice) Slice
- func UniqBy[T any, U comparable, Slice ~[]T](collection Slice, iteratee func(item T) U) Slice
- func UniqKeys[K comparable, V any](in ...map[K]V) []K
- func UniqMap[T any, R comparable](collection []T, iteratee func(item T, index int) R) []R
- func UniqValues[K comparable, V comparable](in ...map[K]V) []V
- func Unpack2[A, B any](tuple Tuple2[A, B]) (A, B)
- func Unpack3[A, B, C any](tuple Tuple3[A, B, C]) (A, B, C)
- func Unpack4[A, B, C, D any](tuple Tuple4[A, B, C, D]) (A, B, C, D)
- func Unpack5[A, B, C, D, E any](tuple Tuple5[A, B, C, D, E]) (A, B, C, D, E)
- func Unpack6[A, B, C, D, E, F any](tuple Tuple6[A, B, C, D, E, F]) (A, B, C, D, E, F)
- func Unpack7[A, B, C, D, E, F, G any](tuple Tuple7[A, B, C, D, E, F, G]) (A, B, C, D, E, F, G)
- func Unpack8[A, B, C, D, E, F, G, H any](tuple Tuple8[A, B, C, D, E, F, G, H]) (A, B, C, D, E, F, G, H)
- func Unpack9[A, B, C, D, E, F, G, H, I any](tuple Tuple9[A, B, C, D, E, F, G, H, I]) (A, B, C, D, E, F, G, H, I)
- func Unzip2[A, B any](tuples []Tuple2[A, B]) ([]A, []B)
- func Unzip3[A, B, C any](tuples []Tuple3[A, B, C]) ([]A, []B, []C)
- func Unzip4[A, B, C, D any](tuples []Tuple4[A, B, C, D]) ([]A, []B, []C, []D)
- func Unzip5[A, B, C, D, E any](tuples []Tuple5[A, B, C, D, E]) ([]A, []B, []C, []D, []E)
- func Unzip6[A, B, C, D, E, F any](tuples []Tuple6[A, B, C, D, E, F]) ([]A, []B, []C, []D, []E, []F)
- func Unzip7[A, B, C, D, E, F, G any](tuples []Tuple7[A, B, C, D, E, F, G]) ([]A, []B, []C, []D, []E, []F, []G)
- func Unzip8[A, B, C, D, E, F, G, H any](tuples []Tuple8[A, B, C, D, E, F, G, H]) ([]A, []B, []C, []D, []E, []F, []G, []H)
- func Unzip9[A, B, C, D, E, F, G, H, I any](tuples []Tuple9[A, B, C, D, E, F, G, H, I]) ([]A, []B, []C, []D, []E, []F, []G, []H, []I)
- func UnzipBy2[In any, A any, B any](items []In, iteratee func(In) (a A, b B)) ([]A, []B)
- func UnzipBy3[In any, A any, B any, C any](items []In, iteratee func(In) (a A, b B, c C)) ([]A, []B, []C)
- func UnzipBy4[In any, A any, B any, C any, D any](items []In, iteratee func(In) (a A, b B, c C, d D)) ([]A, []B, []C, []D)
- func UnzipBy5[In any, A any, B any, C any, D any, E any](items []In, iteratee func(In) (a A, b B, c C, d D, e E)) ([]A, []B, []C, []D, []E)
- func UnzipBy6[In any, A any, B any, C any, D any, E any, F any](items []In, iteratee func(In) (a A, b B, c C, d D, e E, f F)) ([]A, []B, []C, []D, []E, []F)
- func UnzipBy7[In any, A any, B any, C any, D any, E any, F any, G any](items []In, iteratee func(In) (a A, b B, c C, d D, e E, f F, g G)) ([]A, []B, []C, []D, []E, []F, []G)
- func UnzipBy8[In any, A any, B any, C any, D any, E any, F any, G any, H any](items []In, iteratee func(In) (a A, b B, c C, d D, e E, f F, g G, h H)) ([]A, []B, []C, []D, []E, []F, []G, []H)
- func UnzipBy9[In any, A any, B any, C any, D any, E any, F any, G any, H any, I any](items []In, iteratee func(In) (a A, b B, c C, d D, e E, f F, g G, h H, i I)) ([]A, []B, []C, []D, []E, []F, []G, []H, []I)
- func Validate(ok bool, format string, args ...any) error
- func ValueOr[K comparable, V any](in map[K]V, key K, fallback V) V
- func Values[K comparable, V any](in ...map[K]V) []V
- func WaitFor(condition func(i int) bool, timeout time.Duration, ...) (totalIterations int, elapsed time.Duration, conditionFound bool)
- func WaitForWithContext(ctx context.Context, ...) (totalIterations int, elapsed time.Duration, conditionFound bool)
- func Without[T comparable, Slice ~[]T](collection Slice, exclude ...T) Slice
- func WithoutBy[T any, K comparable](collection []T, iteratee func(item T) K, exclude ...K) []T
- func WithoutEmpty[T comparable, Slice ~[]T](collection Slice) Slicedeprecated
- func WithoutNth[T comparable, Slice ~[]T](collection Slice, nths ...int) Slice
- func Words(str string) []string
- func ZipBy2[A any, B any, Out any](a []A, b []B, iteratee func(a A, b B) Out) []Out
- func ZipBy3[A any, B any, C any, Out any](a []A, b []B, c []C, iteratee func(a A, b B, c C) Out) []Out
- func ZipBy4[A any, B any, C any, D any, Out any](a []A, b []B, c []C, d []D, iteratee func(a A, b B, c C, d D) Out) []Out
- func ZipBy5[A any, B any, C any, D any, E any, Out any](a []A, b []B, c []C, d []D, e []E, iteratee func(a A, b B, c C, d D, e E) Out) []Out
- func ZipBy6[A any, B any, C any, D any, E any, F any, Out any](a []A, b []B, c []C, d []D, e []E, f []F, ...) []Out
- func ZipBy7[A any, B any, C any, D any, E any, F any, G any, Out any](a []A, b []B, c []C, d []D, e []E, f []F, g []G, ...) []Out
- func ZipBy8[A any, B any, C any, D any, E any, F any, G any, H any, Out any](a []A, b []B, c []C, d []D, e []E, f []F, g []G, h []H, ...) []Out
- func ZipBy9[A any, B any, C any, D any, E any, F any, G any, H any, I any, Out any](a []A, b []B, c []C, d []D, e []E, f []F, g []G, h []H, i []I, ...) []Out
- type Clonable
- type DispatchingStrategy
- type Entry
- type Transaction
- type Tuple2
- type Tuple3
- type Tuple4
- type Tuple5
- type Tuple6
- func CrossJoin6[A, B, C, D, E, F any](listA []A, listB []B, listC []C, listD []D, listE []E, listF []F) []Tuple6[A, B, C, D, E, F]
- func T6[A, B, C, D, E, F any](a A, b B, c C, d D, e E, f F) Tuple6[A, B, C, D, E, F]
- func Zip6[A, B, C, D, E, F any](a []A, b []B, c []C, d []D, e []E, f []F) []Tuple6[A, B, C, D, E, F]
- type Tuple7
- func CrossJoin7[A, B, C, D, E, F, G any](listA []A, listB []B, listC []C, listD []D, listE []E, listF []F, listG []G) []Tuple7[A, B, C, D, E, F, G]
- func T7[A, B, C, D, E, F, G any](a A, b B, c C, d D, e E, f F, g G) Tuple7[A, B, C, D, E, F, G]
- func Zip7[A, B, C, D, E, F, G any](a []A, b []B, c []C, d []D, e []E, f []F, g []G) []Tuple7[A, B, C, D, E, F, G]
- type Tuple8
- func CrossJoin8[A, B, C, D, E, F, G, H any](listA []A, listB []B, listC []C, listD []D, listE []E, listF []F, listG []G, ...) []Tuple8[A, B, C, D, E, F, G, H]
- func T8[A, B, C, D, E, F, G, H any](a A, b B, c C, d D, e E, f F, g G, h H) Tuple8[A, B, C, D, E, F, G, H]
- func Zip8[A, B, C, D, E, F, G, H any](a []A, b []B, c []C, d []D, e []E, f []F, g []G, h []H) []Tuple8[A, B, C, D, E, F, G, H]
- type Tuple9
- func CrossJoin9[A, B, C, D, E, F, G, H, I any](listA []A, listB []B, listC []C, listD []D, listE []E, listF []F, listG []G, ...) []Tuple9[A, B, C, D, E, F, G, H, I]
- func T9[A, B, C, D, E, F, G, H, I any](a A, b B, c C, d D, e E, f F, g G, h H, i I) Tuple9[A, B, C, D, E, F, G, H, I]
- func Zip9[A, B, C, D, E, F, G, H, I any](a []A, b []B, c []C, d []D, e []E, f []F, g []G, h []H, i []I) []Tuple9[A, B, C, D, E, F, G, H, I]
Constants ¶
This section is empty.
Variables ¶
var ( LowerCaseLettersCharset = []rune("abcdefghijklmnopqrstuvwxyz") UpperCaseLettersCharset = []rune("ABCDEFGHIJKLMNOPQRSTUVWXYZ") LettersCharset = append(LowerCaseLettersCharset, UpperCaseLettersCharset...) NumbersCharset = []rune("0123456789") AlphanumericCharset = append(LettersCharset, NumbersCharset...) SpecialCharset = []rune("!@#$%^&*()_+-=[]{}|;':\",./<>?") AllCharset = append(AlphanumericCharset, SpecialCharset...) )
Functions ¶
func Assign ¶
func Assign[K comparable, V any, Map ~map[K]V](maps ...Map) Map
Assign merges multiple maps from left to right. Play: https://go.dev/play/p/VhwfJOyxf5o
func Associate ¶ added in v1.26.0
func Associate[T any, K comparable, V any](collection []T, transform func(item T) (K, V)) map[K]V
Associate returns a map containing key-value pairs provided by transform function applied to elements of the given slice. If any of two pairs would have the same key the last one gets added to the map. The order of keys in returned map is not specified and is not guaranteed to be the same from the original array. Play: https://go.dev/play/p/WHa2CfMO3Lr
func Async ¶ added in v1.12.0
func Async[A any](f func() A) <-chan A
Async executes a function in a goroutine and returns the result in a channel.
func Async0 ¶ added in v1.17.0
func Async0(f func()) <-chan struct{}
Async0 executes a function in a goroutine and returns a channel set once the function finishes.
func Async2 ¶ added in v1.17.0
Async2 has the same behavior as Async, but returns the 2 results as a tuple inside the channel.
func Async3 ¶ added in v1.17.0
Async3 has the same behavior as Async, but returns the 3 results as a tuple inside the channel.
func Async4 ¶ added in v1.17.0
Async4 has the same behavior as Async, but returns the 4 results as a tuple inside the channel.
func Async5 ¶ added in v1.17.0
Async5 has the same behavior as Async, but returns the 5 results as a tuple inside the channel.
func Async6 ¶ added in v1.17.0
Async6 has the same behavior as Async, but returns the 6 results as a tuple inside the channel.
func Attempt ¶ added in v1.5.0
Attempt invokes a function N times until it returns valid output. Returns either the caught error or nil. When the first argument is less than `1`, the function runs until a successful response is returned. Play: https://go.dev/play/p/3ggJZ2ZKcMj
func AttemptWhile ¶ added in v1.36.0
AttemptWhile invokes a function N times until it returns valid output. Returns either the caught error or nil, along with a bool value to determine whether the function should be invoked again. It will terminate the invoke immediately if the second return value is false. When the first argument is less than `1`, the function runs until a successful response is returned.
func AttemptWhileWithDelay ¶ added in v1.36.0
func AttemptWhileWithDelay(maxIteration int, delay time.Duration, f func(int, time.Duration) (error, bool)) (int, time.Duration, error)
AttemptWhileWithDelay invokes a function N times until it returns valid output, with a pause between each call. Returns either the caught error or nil, along with a bool value to determine whether the function should be invoked again. It will terminate the invoke immediately if the second return value is false. When the first argument is less than `1`, the function runs until a successful response is returned.
func AttemptWithDelay ¶ added in v1.16.0
func AttemptWithDelay(maxIteration int, delay time.Duration, f func(index int, duration time.Duration) error) (int, time.Duration, error)
AttemptWithDelay invokes a function N times until it returns valid output, with a pause between each call. Returns either the caught error or nil. When the first argument is less than `1`, the function runs until a successful response is returned. Play: https://go.dev/play/p/tVs6CygC7m1
func BatchWithTimeout
deprecated
added in
v1.31.0
func Buffer ¶ added in v1.35.0
func Buffer[T any](ch <-chan T, size int) (collection []T, length int, readTime time.Duration, ok bool)
Buffer creates a slice of n elements from a channel. Returns the slice and the slice length. @TODO: we should probably provide an helper that reuse the same buffer.
func BufferWithContext ¶ added in v1.48.0
func BufferWithContext[T any](ctx context.Context, ch <-chan T, size int) (collection []T, length int, readTime time.Duration, ok bool)
BufferWithContext creates a slice of n elements from a channel, with context. Returns the slice and the slice length. @TODO: we should probably provide an helper that reuse the same buffer.
func BufferWithTimeout ¶ added in v1.35.0
func BufferWithTimeout[T any](ch <-chan T, size int, timeout time.Duration) (collection []T, length int, readTime time.Duration, ok bool)
BufferWithTimeout creates a slice of n elements from a channel, with timeout. Returns the slice and the slice length.
func Capitalize ¶ added in v1.40.0
Capitalize converts the first character of string to upper case and the remaining to lower case.
func ChannelDispatcher ¶ added in v1.28.0
func ChannelDispatcher[T any](stream <-chan T, count int, channelBufferCap int, strategy DispatchingStrategy[T]) []<-chan T
ChannelDispatcher distributes messages from input channels into N child channels. Close events are propagated to children. Underlying channels can have a fixed buffer capacity or be unbuffered when cap is 0.
func ChannelMerge
deprecated
added in
v1.33.0
func ChannelToSlice ¶ added in v1.32.0
func ChannelToSlice[T any](ch <-chan T) []T
ChannelToSlice returns a slice built from channels items. Blocks until channel closes.
func Chunk ¶
Chunk returns an array of elements split into groups the length of size. If array can't be split evenly, the final chunk will be the remaining elements. Play: https://go.dev/play/p/EeKl0AuTehH
func ChunkEntries ¶ added in v1.49.0
func ChunkEntries[K comparable, V any](m map[K]V, size int) []map[K]V
ChunkEntries splits a map into an array of elements in groups of a length equal to its size. If the map cannot be split evenly, the final chunk will contain the remaining elements.
func ChunkString ¶ added in v1.27.0
ChunkString returns an array of strings split into groups the length of size. If array can't be split evenly, the final chunk will be the remaining elements. Play: https://go.dev/play/p/__FLTuJVz54
func Clamp ¶ added in v1.13.0
func Clamp[T constraints.Ordered](value T, min T, max T) T
Clamp clamps number within the inclusive lower and upper bounds. Play: https://go.dev/play/p/RU4lJNC2hlI
func Coalesce ¶ added in v1.14.0
func Coalesce[T comparable](values ...T) (result T, ok bool)
Coalesce returns the first non-empty arguments. Arguments must be comparable.
func CoalesceMap ¶ added in v1.48.0
func CoalesceMap[K comparable, V any](v ...map[K]V) (map[K]V, bool)
CoalesceMap returns the first non-zero map.
func CoalesceMapOrEmpty ¶ added in v1.48.0
func CoalesceMapOrEmpty[K comparable, V any](v ...map[K]V) map[K]V
CoalesceMapOrEmpty returns the first non-zero map.
func CoalesceOrEmpty ¶ added in v1.41.0
func CoalesceOrEmpty[T comparable](v ...T) T
CoalesceOrEmpty returns the first non-empty arguments. Arguments must be comparable.
func CoalesceSlice ¶ added in v1.48.0
CoalesceSlice returns the first non-zero slice.
func CoalesceSliceOrEmpty ¶ added in v1.48.0
func CoalesceSliceOrEmpty[T any](v ...[]T) []T
CoalesceSliceOrEmpty returns the first non-zero slice.
func Compact ¶ added in v1.22.0
func Compact[T comparable, Slice ~[]T](collection Slice) Slice
Compact returns a slice of all non-zero elements. Play: https://go.dev/play/p/tXiy-iK6PAc
func Contains ¶
func Contains[T comparable](collection []T, element T) bool
Contains returns true if an element is present in a collection.
func ContainsBy ¶ added in v1.7.0
ContainsBy returns true if predicate function return true.
func Count ¶ added in v1.12.0
func Count[T comparable](collection []T, value T) (count int)
Count counts the number of elements in the collection that compare equal to value. Play: https://go.dev/play/p/Y3FlK54yveC
func CountBy ¶ added in v1.12.0
CountBy counts the number of elements in the collection for which predicate is true. Play: https://go.dev/play/p/ByQbNYQQi4X
func CountValues ¶ added in v1.32.0
func CountValues[T comparable](collection []T) map[T]int
CountValues counts the number of each element in the collection. Play: https://go.dev/play/p/-p-PyLT4dfy
func CountValuesBy ¶ added in v1.32.0
func CountValuesBy[T any, U comparable](collection []T, mapper func(item T) U) map[U]int
CountValuesBy counts the number of each element return from mapper function. Is equivalent to chaining lo.Map and lo.CountValues. Play: https://go.dev/play/p/2U0dG1SnOmS
func CrossJoinBy2 ¶ added in v1.48.0
func CrossJoinBy2[A, B, Out any](listA []A, listB []B, project func(a A, b B) Out) []Out
CrossJoinBy2 combines every items from one list with every items from others. It is the cartesian product of lists received as arguments. The project function is used to create the output values. It returns an empty list if a list is empty.
func CrossJoinBy3 ¶ added in v1.48.0
func CrossJoinBy3[A, B, C, Out any](listA []A, listB []B, listC []C, project func(a A, b B, c C) Out) []Out
CrossJoinBy3 combines every items from one list with every items from others. It is the cartesian product of lists received as arguments. The project function is used to create the output values. It returns an empty list if a list is empty.
func CrossJoinBy4 ¶ added in v1.48.0
func CrossJoinBy4[A, B, C, D, Out any](listA []A, listB []B, listC []C, listD []D, project func(a A, b B, c C, d D) Out) []Out
CrossJoinBy4 combines every items from one list with every items from others. It is the cartesian product of lists received as arguments. The project function is used to create the output values. It returns an empty list if a list is empty.
func CrossJoinBy5 ¶ added in v1.48.0
func CrossJoinBy5[A, B, C, D, E, Out any](listA []A, listB []B, listC []C, listD []D, listE []E, project func(a A, b B, c C, d D, e E) Out) []Out
CrossJoinBy5 combines every items from one list with every items from others. It is the cartesian product of lists received as arguments. The project function is used to create the output values. It returns an empty list if a list is empty.
func CrossJoinBy6 ¶ added in v1.48.0
func CrossJoinBy6[A, B, C, D, E, F, Out any](listA []A, listB []B, listC []C, listD []D, listE []E, listF []F, project func(a A, b B, c C, d D, e E, f F) Out) []Out
CrossJoinBy6 combines every items from one list with every items from others. It is the cartesian product of lists received as arguments. The project function is used to create the output values. It returns an empty list if a list is empty.
func CrossJoinBy7 ¶ added in v1.48.0
func CrossJoinBy7[A, B, C, D, E, F, G, Out any](listA []A, listB []B, listC []C, listD []D, listE []E, listF []F, listG []G, project func(a A, b B, c C, d D, e E, f F, g G) Out) []Out
CrossJoinBy7 combines every items from one list with every items from others. It is the cartesian product of lists received as arguments. The project function is used to create the output values. It returns an empty list if a list is empty.
func CrossJoinBy8 ¶ added in v1.48.0
func CrossJoinBy8[A, B, C, D, E, F, G, H, Out any](listA []A, listB []B, listC []C, listD []D, listE []E, listF []F, listG []G, listH []H, project func(a A, b B, c C, d D, e E, f F, g G, h H) Out) []Out
CrossJoinBy8 combines every items from one list with every items from others. It is the cartesian product of lists received as arguments. The project function is used to create the output values. It returns an empty list if a list is empty.
func CrossJoinBy9 ¶ added in v1.48.0
func CrossJoinBy9[A, B, C, D, E, F, G, H, I, Out any](listA []A, listB []B, listC []C, listD []D, listE []E, listF []F, listG []G, listH []H, listI []I, project func(a A, b B, c C, d D, e E, f F, g G, h H, i I) Out) []Out
CrossJoinBy9 combines every items from one list with every items from others. It is the cartesian product of lists received as arguments. The project function is used to create the output values. It returns an empty list if a list is empty.
func Difference ¶
func Difference[T comparable, Slice ~[]T](list1 Slice, list2 Slice) (Slice, Slice)
Difference returns the difference between two collections. The first value is the collection of element absent of list2. The second value is the collection of element absent of list1.
func DispatchingStrategyFirst ¶ added in v1.28.0
DispatchingStrategyFirst distributes messages in the first non-full channel. If the capacity of the first channel is exceeded, the second channel will be selected and so on.
func DispatchingStrategyLeast ¶ added in v1.28.0
DispatchingStrategyLeast distributes messages in the emptiest channel.
func DispatchingStrategyMost ¶ added in v1.28.0
DispatchingStrategyMost distributes messages in the fullest channel. If the channel capacity is exceeded, the next channel will be selected and so on.
func DispatchingStrategyRandom ¶ added in v1.28.0
DispatchingStrategyRandom distributes messages in a random manner. If the channel capacity is exceeded, another random channel will be selected and so on.
func DispatchingStrategyRoundRobin ¶ added in v1.28.0
DispatchingStrategyRoundRobin distributes messages in a rotating sequential manner. If the channel capacity is exceeded, the next channel will be selected and so on.
func Drop ¶ added in v1.9.0
Drop drops n elements from the beginning of a slice or array. Play: https://go.dev/play/p/JswS7vXRJP2
func DropByIndex ¶ added in v1.44.0
DropByIndex drops elements from a slice or array by the index. A negative index will drop elements from the end of the slice. Play: https://go.dev/play/p/bPIH4npZRxS
func DropRight ¶ added in v1.9.0
DropRight drops n elements from the end of a slice or array. Play: https://go.dev/play/p/GG0nXkSJJa3
func DropRightWhile ¶ added in v1.9.0
DropRightWhile drops elements from the end of a slice or array while the predicate returns true. Play: https://go.dev/play/p/3-n71oEC0Hz
func DropWhile ¶ added in v1.9.0
DropWhile drops elements from the beginning of a slice or array while the predicate returns true. Play: https://go.dev/play/p/7gBPYw2IK16
func Duration10 ¶ added in v1.41.0
func Duration10[A, B, C, D, E, F, G, H, I, J any](cb func() (A, B, C, D, E, F, G, H, I, J)) (A, B, C, D, E, F, G, H, I, J, time.Duration)
Duration10 returns the time taken to execute a function.
func Duration6 ¶ added in v1.41.0
func Duration6[A, B, C, D, E, F any](cb func() (A, B, C, D, E, F)) (A, B, C, D, E, F, time.Duration)
Duration6 returns the time taken to execute a function.
func Duration7 ¶ added in v1.41.0
func Duration7[A, B, C, D, E, F, G any](cb func() (A, B, C, D, E, F, G)) (A, B, C, D, E, F, G, time.Duration)
Duration7 returns the time taken to execute a function.
func Duration8 ¶ added in v1.41.0
func Duration8[A, B, C, D, E, F, G, H any](cb func() (A, B, C, D, E, F, G, H)) (A, B, C, D, E, F, G, H, time.Duration)
Duration8 returns the time taken to execute a function.
func Duration9 ¶ added in v1.41.0
func Duration9[A, B, C, D, E, F, G, H, I any](cb func() (A, B, C, D, E, F, G, H, I)) (A, B, C, D, E, F, G, H, I, time.Duration)
Duration9 returns the time taken to execute a function.
func Earliest ¶ added in v1.41.0
Earliest search the minimum time.Time of a collection. Returns zero value when the collection is empty.
func EarliestBy ¶ added in v1.45.0
EarliestBy search the minimum time.Time of a collection using the given iteratee function. Returns zero value when the collection is empty.
func Ellipsis ¶ added in v1.48.0
Ellipsis trims and truncates a string to a specified length and appends an ellipsis if truncated.
func Empty ¶ added in v1.6.0
func Empty[T any]() T
Empty returns the zero value (https://go.dev/ref/spec#The_zero_value).
func EmptyableToPtr ¶ added in v1.38.0
func EmptyableToPtr[T any](x T) *T
EmptyableToPtr returns a pointer copy of value if it's nonzero. Otherwise, returns nil pointer.
func ErrorsAs ¶ added in v1.29.0
ErrorsAs is a shortcut for errors.As(err, &&T). Play: https://go.dev/play/p/8wk5rH8UfrE
func Every ¶
func Every[T comparable](collection []T, subset []T) bool
Every returns true if all elements of a subset are contained into a collection or if the subset is empty.
func EveryBy ¶ added in v1.18.0
EveryBy returns true if the predicate returns true for all elements in the collection or if the collection is empty.
func FanIn ¶ added in v1.34.0
FanIn collects messages from multiple input channels into a single buffered channel. Output messages has no priority. When all upstream channels reach EOF, downstream channel closes.
func FanOut ¶ added in v1.34.0
FanOut broadcasts all the upstream messages to multiple downstream channels. When upstream channel reach EOF, downstream channels close. If any downstream channels is full, broadcasting is paused.
func Fill ¶
func Fill[T Clonable[T], Slice ~[]T](collection Slice, initial T) Slice
Fill fills elements of array with `initial` value. Play: https://go.dev/play/p/VwR34GzqEub
func Filter ¶
Filter iterates over elements of collection, returning an array of all elements predicate returns truthy for. Play: https://go.dev/play/p/Apjg3WeSi7K
func FilterMap ¶ added in v1.12.0
FilterMap returns a slice which obtained after both filtering and mapping using the given callback function. The callback function should return two values:
- the result of the mapping operation and
- whether the result element should be included or not.
func FilterReject ¶ added in v1.41.0
func FilterReject[T any, Slice ~[]T](collection Slice, predicate func(T, int) bool) (kept Slice, rejected Slice)
FilterReject mixes Filter and Reject, this method returns two slices, one for the elements of collection that predicate returns truthy for and one for the elements that predicate does not return truthy for.
func FilterSliceToMap ¶ added in v1.49.0
func FilterSliceToMap[T any, K comparable, V any](collection []T, transform func(item T) (K, V, bool)) map[K]V
FilterSliceToMap returns a map containing key-value pairs provided by transform function applied to elements of the given slice. If any of two pairs would have the same key the last one gets added to the map. The order of keys in returned map is not specified and is not guaranteed to be the same from the original array. The third return value of the transform function is a boolean that indicates whether the key-value pair should be included in the map.
func Find ¶
Find search an element in a slice based on a predicate. It returns element and true if element was found.
func FindDuplicates ¶ added in v1.25.0
func FindDuplicates[T comparable, Slice ~[]T](collection Slice) Slice
FindDuplicates returns a slice with the first occurrence of each duplicated elements of the collection. The order of result values is determined by the order they occur in the collection.
func FindDuplicatesBy ¶ added in v1.25.0
func FindDuplicatesBy[T any, U comparable, Slice ~[]T](collection Slice, iteratee func(item T) U) Slice
FindDuplicatesBy returns a slice with the first occurrence of each duplicated elements of the collection. The order of result values is determined by the order they occur in the array. It accepts `iteratee` which is invoked for each element in array to generate the criterion by which uniqueness is computed.
func FindIndexOf ¶ added in v1.12.0
FindIndexOf searches an element in a slice based on a predicate and returns the index and true. It returns -1 and false if the element is not found.
func FindKey ¶ added in v1.23.0
func FindKey[K comparable, V comparable](object map[K]V, value V) (K, bool)
FindKey returns the key of the first value matching.
func FindKeyBy ¶ added in v1.23.0
func FindKeyBy[K comparable, V any](object map[K]V, predicate func(key K, value V) bool) (K, bool)
FindKeyBy returns the key of the first element predicate returns truthy for.
func FindLastIndexOf ¶ added in v1.12.0
FindLastIndexOf searches last element in a slice based on a predicate and returns the index and true. It returns -1 and false if the element is not found.
func FindOrElse ¶ added in v1.12.0
FindOrElse search an element in a slice based on a predicate. It returns the element if found or a given fallback value otherwise.
func FindUniques ¶ added in v1.25.0
func FindUniques[T comparable, Slice ~[]T](collection Slice) Slice
FindUniques returns a slice with all the unique elements of the collection. The order of result values is determined by the order they occur in the collection.
func FindUniquesBy ¶ added in v1.25.0
func FindUniquesBy[T any, U comparable, Slice ~[]T](collection Slice, iteratee func(item T) U) Slice
FindUniquesBy returns a slice with all the unique elements of the collection. The order of result values is determined by the order they occur in the array. It accepts `iteratee` which is invoked for each element in array to generate the criterion by which uniqueness is computed.
func First ¶ added in v1.42.0
First returns the first element of a collection and check for availability of the first element.
func FirstOr ¶ added in v1.42.0
func FirstOr[T any](collection []T, fallback T) T
FirstOr returns the first element of a collection or the fallback value if empty.
func FirstOrEmpty ¶ added in v1.42.0
func FirstOrEmpty[T any](collection []T) T
FirstOrEmpty returns the first element of a collection or zero value if empty.
func FlatMap ¶ added in v1.7.0
FlatMap manipulates a slice and transforms and flattens it to a slice of another type. The transform function can either return a slice or a `nil`, and in the `nil` case no value is added to the final slice. Play: https://go.dev/play/p/YSoYmQTA8-U
func Flatten ¶
func Flatten[T any, Slice ~[]T](collection []Slice) Slice
Flatten returns an array a single level deep. Play: https://go.dev/play/p/rbp9ORaMpjw
func ForEach ¶
ForEach iterates over elements of collection and invokes iteratee for each element. Play: https://go.dev/play/p/oofyiUPRf8t
func ForEachWhile ¶ added in v1.46.0
ForEachWhile iterates over elements of collection and invokes iteratee for each element collection return value decide to continue or break, like do while(). Play: https://go.dev/play/p/QnLGt35tnow
func FromAnySlice ¶ added in v1.21.0
FromAnySlice returns an `any` slice with all elements mapped to a type. Returns false in case of type conversion failure.
func FromEntries ¶
func FromEntries[K comparable, V any](entries []Entry[K, V]) map[K]V
FromEntries transforms an array of key/value pairs into a map. Play: https://go.dev/play/p/oIr5KHFGCEN
func FromPairs ¶ added in v1.22.0
func FromPairs[K comparable, V any](entries []Entry[K, V]) map[K]V
FromPairs transforms an array of key/value pairs into a map. Alias of FromEntries(). Play: https://go.dev/play/p/oIr5KHFGCEN
func FromPtr ¶ added in v1.22.0
func FromPtr[T any](x *T) T
FromPtr returns the pointer value or empty.
func FromPtrOr ¶ added in v1.26.0
func FromPtrOr[T any](x *T, fallback T) T
FromPtrOr returns the pointer value or the fallback value.
func FromSlicePtr ¶ added in v1.47.0
func FromSlicePtr[T any](collection []*T) []T
FromSlicePtr returns a slice with the pointer values. Returns a zero value in case of a nil pointer element.
func FromSlicePtrOr ¶ added in v1.47.0
func FromSlicePtrOr[T any](collection []*T, fallback T) []T
FromSlicePtrOr returns a slice with the pointer values or the fallback value. Play: https://go.dev/play/p/lbunFvzlUDX
func GroupBy ¶
func GroupBy[T any, U comparable, Slice ~[]T](collection Slice, iteratee func(item T) U) map[U]Slice
GroupBy returns an object composed of keys generated from the results of running each element of collection through iteratee. Play: https://go.dev/play/p/XnQBd_v6brd
func HasKey ¶ added in v1.43.0
func HasKey[K comparable, V any](in map[K]V, key K) bool
HasKey returns whether the given key exists. Play: https://go.dev/play/p/aVwubIvECqS
func If ¶
If. Play: https://go.dev/play/p/WSw3ApMxhyW
func IfF ¶ added in v1.13.0
IfF. Play: https://go.dev/play/p/WSw3ApMxhyW
func IndexOf ¶
func IndexOf[T comparable](collection []T, element T) int
IndexOf returns the index at which the first occurrence of a value is found in an array or return -1 if the value cannot be found.
func Interleave ¶ added in v1.32.0
func Interleave[T any, Slice ~[]T](collections ...Slice) Slice
Interleave round-robin alternating input slices and sequentially appending value at index into result Play: https://go.dev/play/p/-RJkTLQEDVt
func Intersect ¶
func Intersect[T comparable, Slice ~[]T](list1 Slice, list2 Slice) Slice
Intersect returns the intersection between two collections.
func Invert ¶ added in v1.13.0
func Invert[K comparable, V comparable](in map[K]V) map[V]K
Invert creates a map composed of the inverted keys and values. If map contains duplicate values, subsequent values overwrite property assignments of previous values. Play: https://go.dev/play/p/rFQ4rak6iA1
func IsEmpty ¶ added in v1.22.0
func IsEmpty[T comparable](v T) bool
IsEmpty returns true if argument is a zero value.
func IsNil ¶ added in v1.39.0
IsNil checks if a value is nil or if it's a reference type with a nil underlying value.
func IsNotEmpty ¶ added in v1.25.0
func IsNotEmpty[T comparable](v T) bool
IsNotEmpty returns true if argument is not a zero value.
func IsNotNil ¶ added in v1.49.0
IsNotNil checks if a value is not nil or if it's not a reference type with a nil underlying value.
func IsSorted ¶ added in v1.26.0
func IsSorted[T constraints.Ordered](collection []T) bool
IsSorted checks if a slice is sorted. Play: https://go.dev/play/p/mc3qR-t4mcx
func IsSortedByKey ¶ added in v1.26.0
func IsSortedByKey[T any, K constraints.Ordered](collection []T, iteratee func(item T) K) bool
IsSortedByKey checks if a slice is sorted by iteratee. Play: https://go.dev/play/p/wiG6XyBBu49
func KeyBy ¶ added in v1.10.1
func KeyBy[K comparable, V any](collection []V, iteratee func(item V) K) map[K]V
KeyBy transforms a slice or an array of structs to a map based on a pivot callback. Play: https://go.dev/play/p/mdaClUAT-zZ
func Keyify ¶ added in v1.48.0
func Keyify[T comparable, Slice ~[]T](collection Slice) map[T]struct{}
Keyify returns a map with each unique element of the slice as a key.
func Keys ¶
func Keys[K comparable, V any](in ...map[K]V) []K
Keys creates an array of the map keys. Play: https://go.dev/play/p/Uu11fHASqrU
func LastIndexOf ¶
func LastIndexOf[T comparable](collection []T, element T) int
LastIndexOf returns the index at which the last occurrence of a value is found in an array or return -1 if the value cannot be found.
func LastOr ¶ added in v1.42.0
func LastOr[T any](collection []T, fallback T) T
LastOr returns the last element of a collection or the fallback value if empty.
func LastOrEmpty ¶ added in v1.42.0
func LastOrEmpty[T any](collection []T) T
LastOrEmpty returns the last element of a collection or zero value if empty.
func Latest ¶ added in v1.41.0
Latest search the maximum time.Time of a collection. Returns zero value when the collection is empty.
func LatestBy ¶ added in v1.45.0
LatestBy search the maximum time.Time of a collection using the given iteratee function. Returns zero value when the collection is empty.
func Map ¶
Map manipulates a slice and transforms it to a slice of another type. Play: https://go.dev/play/p/OkPcYAhBo0D
func MapEntries ¶ added in v1.32.0
func MapEntries[K1 comparable, V1 any, K2 comparable, V2 any](in map[K1]V1, iteratee func(key K1, value V1) (K2, V2)) map[K2]V2
MapEntries manipulates a map entries and transforms it to a map of another type. Play: https://go.dev/play/p/VuvNQzxKimT
func MapKeys ¶ added in v1.13.0
func MapKeys[K comparable, V any, R comparable](in map[K]V, iteratee func(value V, key K) R) map[R]V
MapKeys manipulates a map keys and transforms it to a map of another type. Play: https://go.dev/play/p/9_4WPIqOetJ
func MapToSlice ¶ added in v1.26.0
func MapToSlice[K comparable, V any, R any](in map[K]V, iteratee func(key K, value V) R) []R
MapToSlice transforms a map into a slice based on specific iteratee Play: https://go.dev/play/p/ZuiCZpDt6LD
func MapValues ¶ added in v1.7.0
func MapValues[K comparable, V any, R any](in map[K]V, iteratee func(value V, key K) R) map[K]R
MapValues manipulates a map values and transforms it to a map of another type. Play: https://go.dev/play/p/T_8xAfvcf0W
func Max ¶
func Max[T constraints.Ordered](collection []T) T
Max searches the maximum value of a collection. Returns zero value when the collection is empty.
func MaxBy ¶ added in v1.12.0
MaxBy search the maximum value of a collection using the given comparison function. If several values of the collection are equal to the greatest value, returns the first such value. Returns zero value when the collection is empty.
func MaxIndex ¶ added in v1.48.0
func MaxIndex[T constraints.Ordered](collection []T) (T, int)
MaxIndex searches the maximum value of a collection and the index of the maximum value. Returns (zero value, -1) when the collection is empty.
func MaxIndexBy ¶ added in v1.48.0
MaxIndexBy search the maximum value of a collection using the given comparison function and the index of the maximum value. If several values of the collection are equal to the greatest value, returns the first such value. Returns (zero value, -1) when the collection is empty.
func Mean ¶ added in v1.40.0
func Mean[T constraints.Float | constraints.Integer](collection []T) T
Mean calculates the mean of a collection of numbers.
func MeanBy ¶ added in v1.40.0
func MeanBy[T any, R constraints.Float | constraints.Integer](collection []T, iteratee func(item T) R) R
MeanBy calculates the mean of a collection of numbers using the given return value from the iteration function.
func Min ¶
func Min[T constraints.Ordered](collection []T) T
Min search the minimum value of a collection. Returns zero value when the collection is empty.
func MinBy ¶ added in v1.12.0
MinBy search the minimum value of a collection using the given comparison function. If several values of the collection are equal to the smallest value, returns the first such value. Returns zero value when the collection is empty.
func MinIndex ¶ added in v1.48.0
func MinIndex[T constraints.Ordered](collection []T) (T, int)
MinIndex search the minimum value of a collection and the index of the minimum value. Returns (zero value, -1) when the collection is empty.
func MinIndexBy ¶ added in v1.48.0
MinIndexBy search the minimum value of a collection using the given comparison function and the index of the minimum value. If several values of the collection are equal to the smallest value, returns the first such value. Returns (zero value, -1) when the collection is empty.
func Must ¶ added in v1.12.0
Must is a helper that wraps a call to a function returning a value and an error and panics if err is error or false. Play: https://go.dev/play/p/TMoWrRp3DyC
func Must0 ¶ added in v1.12.0
Must0 has the same behavior as Must, but callback returns no variable. Play: https://go.dev/play/p/TMoWrRp3DyC
func Must1 ¶ added in v1.12.0
Must1 is an alias to Must Play: https://go.dev/play/p/TMoWrRp3DyC
func Must2 ¶ added in v1.12.0
Must2 has the same behavior as Must, but callback returns 2 variables. Play: https://go.dev/play/p/TMoWrRp3DyC
func Must3 ¶ added in v1.12.0
Must3 has the same behavior as Must, but callback returns 3 variables. Play: https://go.dev/play/p/TMoWrRp3DyC
func Must4 ¶ added in v1.12.0
func Must4[T1, T2, T3, T4 any](val1 T1, val2 T2, val3 T3, val4 T4, err any, messageArgs ...any) (T1, T2, T3, T4)
Must4 has the same behavior as Must, but callback returns 4 variables. Play: https://go.dev/play/p/TMoWrRp3DyC
func Must5 ¶ added in v1.12.0
func Must5[T1, T2, T3, T4, T5 any](val1 T1, val2 T2, val3 T3, val4 T4, val5 T5, err any, messageArgs ...any) (T1, T2, T3, T4, T5)
Must5 has the same behavior as Must, but callback returns 5 variables. Play: https://go.dev/play/p/TMoWrRp3DyC
func Must6 ¶ added in v1.12.0
func Must6[T1, T2, T3, T4, T5, T6 any](val1 T1, val2 T2, val3 T3, val4 T4, val5 T5, val6 T6, err any, messageArgs ...any) (T1, T2, T3, T4, T5, T6)
Must6 has the same behavior as Must, but callback returns 6 variables. Play: https://go.dev/play/p/TMoWrRp3DyC
func NewDebounce ¶ added in v1.11.0
NewDebounce creates a debounced instance that delays invoking functions given until after wait milliseconds have elapsed. Play: https://go.dev/play/p/mz32VMK2nqe
func NewDebounceBy ¶ added in v1.38.0
func NewDebounceBy[T comparable](duration time.Duration, f ...func(key T, count int)) (func(key T), func(key T))
NewDebounceBy creates a debounced instance for each distinct key, that delays invoking functions given until after wait milliseconds have elapsed. Play: https://go.dev/play/p/d3Vpt6pxhY8
func NewThrottle ¶ added in v1.49.0
NewThrottle creates a throttled instance that invokes given functions only once in every interval. This returns 2 functions, First one is throttled function and Second one is a function to reset interval
func NewThrottleBy ¶ added in v1.49.0
func NewThrottleBy[T comparable](interval time.Duration, f ...func(key T)) (throttle func(key T), reset func())
NewThrottleBy creates a throttled instance that invokes given functions only once in every interval. This returns 2 functions, First one is throttled function and Second one is a function to reset interval
func NewThrottleByWithCount ¶ added in v1.49.0
func NewThrottleByWithCount[T comparable](interval time.Duration, count int, f ...func(key T)) (throttle func(key T), reset func())
NewThrottleByWithCount is NewThrottleBy with count limit, throttled function will be invoked count times in every interval.
func NewThrottleWithCount ¶ added in v1.49.0
func NewThrottleWithCount(interval time.Duration, count int, f ...func()) (throttle func(), reset func())
NewThrottleWithCount is NewThrottle with count limit, throttled function will be invoked count times in every interval.
func None ¶ added in v1.18.0
func None[T comparable](collection []T, subset []T) bool
None returns true if no element of a subset are contained into a collection or if the subset is empty.
func NoneBy ¶ added in v1.18.0
NoneBy returns true if the predicate returns true for none of the elements in the collection or if the collection is empty.
func Nth ¶
func Nth[T any, N constraints.Integer](collection []T, nth N) (T, error)
Nth returns the element at index `nth` of collection. If `nth` is negative, the nth element from the end is returned. An error is returned when nth is out of slice bounds.
func OmitBy ¶ added in v1.13.0
func OmitBy[K comparable, V any, Map ~map[K]V](in Map, predicate func(key K, value V) bool) Map
OmitBy returns same map type filtered by given predicate. Play: https://go.dev/play/p/EtBsR43bdsd
func OmitByKeys ¶ added in v1.13.0
func OmitByKeys[K comparable, V any, Map ~map[K]V](in Map, keys []K) Map
OmitByKeys returns same map type filtered by given keys. Play: https://go.dev/play/p/t1QjCrs-ysk
func OmitByValues ¶ added in v1.13.0
func OmitByValues[K comparable, V comparable, Map ~map[K]V](in Map, values []V) Map
OmitByValues returns same map type filtered by given values. Play: https://go.dev/play/p/9UYZi-hrs8j
func Partial ¶ added in v1.22.0
func Partial[T1, T2, R any](f func(a T1, b T2) R, arg1 T1) func(T2) R
Partial returns new function that, when called, has its first argument set to the provided value.
func Partial1 ¶ added in v1.37.0
func Partial1[T1, T2, R any](f func(T1, T2) R, arg1 T1) func(T2) R
Partial1 returns new function that, when called, has its first argument set to the provided value.
func Partial2 ¶ added in v1.37.0
func Partial2[T1, T2, T3, R any](f func(T1, T2, T3) R, arg1 T1) func(T2, T3) R
Partial2 returns new function that, when called, has its first argument set to the provided value.
func Partial3 ¶ added in v1.37.0
func Partial3[T1, T2, T3, T4, R any](f func(T1, T2, T3, T4) R, arg1 T1) func(T2, T3, T4) R
Partial3 returns new function that, when called, has its first argument set to the provided value.
func Partial4 ¶ added in v1.37.0
func Partial4[T1, T2, T3, T4, T5, R any](f func(T1, T2, T3, T4, T5) R, arg1 T1) func(T2, T3, T4, T5) R
Partial4 returns new function that, when called, has its first argument set to the provided value.
func Partial5 ¶ added in v1.37.0
func Partial5[T1, T2, T3, T4, T5, T6, R any](f func(T1, T2, T3, T4, T5, T6) R, arg1 T1) func(T2, T3, T4, T5, T6) R
Partial5 returns new function that, when called, has its first argument set to the provided value
func PartitionBy ¶ added in v1.4.0
func PartitionBy[T any, K comparable, Slice ~[]T](collection Slice, iteratee func(item T) K) []Slice
PartitionBy returns an array of elements split into groups. The order of grouped values is determined by the order they occur in collection. The grouping is generated from the results of running each element of collection through iteratee. Play: https://go.dev/play/p/NfQ_nGjkgXW
func PascalCase ¶ added in v1.40.0
PascalCase converts string to pascal case.
func PickBy ¶ added in v1.13.0
func PickBy[K comparable, V any, Map ~map[K]V](in Map, predicate func(key K, value V) bool) Map
PickBy returns same map type filtered by given predicate. Play: https://go.dev/play/p/kdg8GR_QMmf
func PickByKeys ¶ added in v1.13.0
func PickByKeys[K comparable, V any, Map ~map[K]V](in Map, keys []K) Map
PickByKeys returns same map type filtered by given keys. Play: https://go.dev/play/p/R1imbuci9qU
func PickByValues ¶ added in v1.13.0
func PickByValues[K comparable, V comparable, Map ~map[K]V](in Map, values []V) Map
PickByValues returns same map type filtered by given values. Play: https://go.dev/play/p/1zdzSvbfsJc
func Product ¶ added in v1.49.0
func Product[T constraints.Float | constraints.Integer | constraints.Complex](collection []T) T
Product gets the product of the values in a collection. If collection is empty 0 is returned. Play: https://go.dev/play/p/2_kjM_smtAH
func ProductBy ¶ added in v1.49.0
func ProductBy[T any, R constraints.Float | constraints.Integer | constraints.Complex](collection []T, iteratee func(item T) R) R
ProductBy summarizes the values in a collection using the given return value from the iteration function. If collection is empty 0 is returned. Play: https://go.dev/play/p/wadzrWr9Aer
func RandomString ¶ added in v1.35.0
RandomString return a random string. Play: https://go.dev/play/p/rRseOQVVum4
func Range ¶ added in v1.10.0
Range creates an array of numbers (positive and/or negative) with given length. Play: https://go.dev/play/p/0r6VimXAi9H
func RangeFrom ¶ added in v1.10.0
func RangeFrom[T constraints.Integer | constraints.Float](start T, elementNum int) []T
RangeFrom creates an array of numbers from start with specified length. Play: https://go.dev/play/p/0r6VimXAi9H
func RangeWithSteps ¶ added in v1.10.0
func RangeWithSteps[T constraints.Integer | constraints.Float](start, end, step T) []T
RangeWithSteps creates an array of numbers (positive and/or negative) progressing from start up to, but not including end. step set to zero will return empty array. Play: https://go.dev/play/p/0r6VimXAi9H
func Reduce ¶
func Reduce[T any, R any](collection []T, accumulator func(agg R, item T, index int) R, initial R) R
Reduce reduces collection to a value which is the accumulated result of running each element in collection through accumulator, where each successive invocation is supplied the return value of the previous. Play: https://go.dev/play/p/R4UHXZNaaUG
func ReduceRight ¶ added in v1.26.0
func ReduceRight[T any, R any](collection []T, accumulator func(agg R, item T, index int) R, initial R) R
ReduceRight helper is like Reduce except that it iterates over elements of collection from right to left. Play: https://go.dev/play/p/Fq3W70l7wXF
func Reject ¶ added in v1.11.0
Reject is the opposite of Filter, this method returns the elements of collection that predicate does not return truthy for. Play: https://go.dev/play/p/YkLMODy1WEL
func RejectMap ¶ added in v1.41.0
RejectMap is the opposite of FilterMap, this method returns a slice which obtained after both filtering and mapping using the given callback function. The callback function should return two values:
- the result of the mapping operation and
- whether the result element should be included or not.
func Repeat ¶ added in v1.5.0
Repeat builds a slice with N copies of initial value. Play: https://go.dev/play/p/g3uHXbmc3b6
func RepeatBy ¶ added in v1.19.0
RepeatBy builds a slice with values returned by N calls of callback. Play: https://go.dev/play/p/ozZLCtX_hNU
func Replace ¶ added in v1.19.0
func Replace[T comparable, Slice ~[]T](collection Slice, old T, new T, n int) Slice
Replace returns a copy of the slice with the first n non-overlapping instances of old replaced by new. Play: https://go.dev/play/p/XfPzmf9gql6
func ReplaceAll ¶ added in v1.19.0
func ReplaceAll[T comparable, Slice ~[]T](collection Slice, old T, new T) Slice
ReplaceAll returns a copy of the slice with all non-overlapping instances of old replaced by new. Play: https://go.dev/play/p/a9xZFUHfYcV
func Reverse
deprecated
func Reverse[T any, Slice ~[]T](collection Slice) Slice
Reverse reverses array so that the first element becomes the last, the second element becomes the second to last, and so on. Play: https://go.dev/play/p/iv2e9jslfBM
Deprecated: use mutable.Reverse() instead.
func RuneLength ¶ added in v1.19.0
RuneLength is an alias to utf8.RuneCountInString which returns the number of runes in string. Play: https://go.dev/play/p/tuhgW_lWY8l
func Sample ¶ added in v1.6.0
func Sample[T any](collection []T) T
Sample returns a random item from collection.
func SampleBy ¶ added in v1.49.0
func SampleBy[T any](collection []T, randomIntGenerator randomIntGenerator) T
SampleBy returns a random item from collection, using randomIntGenerator as the random index generator.
func SamplesBy ¶ added in v1.49.0
func SamplesBy[T any, Slice ~[]T](collection Slice, count int, randomIntGenerator randomIntGenerator) Slice
SamplesBy returns N random unique items from collection, using randomIntGenerator as the random index generator.
func Shuffle
deprecated
func Shuffle[T any, Slice ~[]T](collection Slice) Slice
Shuffle returns an array of shuffled values. Uses the Fisher-Yates shuffle algorithm. Play: https://go.dev/play/p/ZTGG7OUCdnp
Deprecated: use mutable.Shuffle() instead.
func Slice ¶ added in v1.22.0
Slice returns a copy of a slice from `start` up to, but not including `end`. Like `slice[start:end]`, but does not panic on overflow. Play: https://go.dev/play/p/8XWYhfMMA1h
func SliceToChannel ¶ added in v1.31.0
SliceToChannel returns a read-only channels of collection elements.
func SliceToMap ¶ added in v1.27.0
func SliceToMap[T any, K comparable, V any](collection []T, transform func(item T) (K, V)) map[K]V
SliceToMap returns a map containing key-value pairs provided by transform function applied to elements of the given slice. If any of two pairs would have the same key the last one gets added to the map. The order of keys in returned map is not specified and is not guaranteed to be the same from the original array. Alias of Associate(). Play: https://go.dev/play/p/WHa2CfMO3Lr
func Some ¶
func Some[T comparable](collection []T, subset []T) bool
Some returns true if at least 1 element of a subset is contained into a collection. If the subset is empty Some returns false.
func SomeBy ¶ added in v1.18.0
SomeBy returns true if the predicate returns true for any of the elements in the collection. If the collection is empty SomeBy returns false.
func Splice ¶ added in v1.44.0
Splice inserts multiple elements at index i. A negative index counts back from the end of the slice. The helper is protected against overflow errors. Play: https://go.dev/play/p/G5_GhkeSUBA
func Subset ¶ added in v1.19.0
Subset returns a copy of a slice from `offset` up to `length` elements. Like `slice[start:start+length]`, but does not panic on overflow. Play: https://go.dev/play/p/tOQu1GhFcog
func Substring ¶ added in v1.19.0
Substring return part of a string. Play: https://go.dev/play/p/TQlxQi82Lu1
func Sum ¶ added in v1.32.0
func Sum[T constraints.Float | constraints.Integer | constraints.Complex](collection []T) T
Sum sums the values in a collection. If collection is empty 0 is returned. Play: https://go.dev/play/p/upfeJVqs4Bt
func SumBy ¶ added in v1.20.0
func SumBy[T any, R constraints.Float | constraints.Integer | constraints.Complex](collection []T, iteratee func(item T) R) R
SumBy summarizes the values in a collection using the given return value from the iteration function. If collection is empty 0 is returned. Play: https://go.dev/play/p/Dz_a_7jN_ca
func Switch ¶
func Switch[T comparable, R any](predicate T) *switchCase[T, R]
Switch is a pure functional switch/case/default statement. Play: https://go.dev/play/p/TGbKUMAeRUd
func Synchronize ¶ added in v1.20.0
Synchronize wraps the underlying callback in a mutex. It receives an optional mutex.
func Ternary ¶
Ternary is a 1 line if/else statement. Play: https://go.dev/play/p/t-D7WBL44h2
func TernaryF ¶ added in v1.30.0
TernaryF is a 1 line if/else statement whose options are functions Play: https://go.dev/play/p/AO4VW20JoqM
func Times ¶ added in v1.5.0
Times invokes the iteratee n times, returning an array of the results of each invocation. The iteratee is invoked with index as argument. Play: https://go.dev/play/p/vgQj3Glr6lT
func ToAnySlice ¶ added in v1.21.0
ToAnySlice returns a slice with all elements mapped to `any` type
func ToSlicePtr ¶
func ToSlicePtr[T any](collection []T) []*T
ToSlicePtr returns a slice of pointer copy of value.
func Try0 ¶ added in v1.11.0
func Try0(callback func()) bool
Try0 has the same behavior as Try, but callback returns no variable. Play: https://go.dev/play/p/mTyyWUvn9u4
func Try1 ¶ added in v1.11.0
Try1 is an alias to Try. Play: https://go.dev/play/p/mTyyWUvn9u4
func Try2 ¶ added in v1.11.0
Try2 has the same behavior as Try, but callback returns 2 variables. Play: https://go.dev/play/p/mTyyWUvn9u4
func Try3 ¶ added in v1.11.0
Try3 has the same behavior as Try, but callback returns 3 variables. Play: https://go.dev/play/p/mTyyWUvn9u4
func Try4 ¶ added in v1.11.0
Try4 has the same behavior as Try, but callback returns 4 variables. Play: https://go.dev/play/p/mTyyWUvn9u4
func Try5 ¶ added in v1.11.0
Try5 has the same behavior as Try, but callback returns 5 variables. Play: https://go.dev/play/p/mTyyWUvn9u4
func Try6 ¶ added in v1.11.0
Try6 has the same behavior as Try, but callback returns 6 variables. Play: https://go.dev/play/p/mTyyWUvn9u4
func TryCatch ¶ added in v1.11.0
func TryCatch(callback func() error, catch func())
TryCatch has the same behavior as Try, but calls the catch function in case of error. Play: https://go.dev/play/p/PnOON-EqBiU
func TryCatchWithErrorValue ¶ added in v1.11.0
TryCatchWithErrorValue has the same behavior as TryWithErrorValue, but calls the catch function in case of error. Play: https://go.dev/play/p/8Pc9gwX_GZO
func TryOr ¶ added in v1.29.0
TryOr has the same behavior as Must, but returns a default value in case of error. Play: https://go.dev/play/p/B4F7Wg2Zh9X
func TryOr1 ¶ added in v1.29.0
TryOr1 has the same behavior as Must, but returns a default value in case of error. Play: https://go.dev/play/p/B4F7Wg2Zh9X
func TryOr2 ¶ added in v1.29.0
TryOr2 has the same behavior as Must, but returns a default value in case of error. Play: https://go.dev/play/p/B4F7Wg2Zh9X
func TryOr3 ¶ added in v1.29.0
func TryOr3[A, B, C any](callback func() (A, B, C, error), fallbackA A, fallbackB B, fallbackC C) (A, B, C, bool)
TryOr3 has the same behavior as Must, but returns a default value in case of error. Play: https://go.dev/play/p/B4F7Wg2Zh9X
func TryOr4 ¶ added in v1.29.0
func TryOr4[A, B, C, D any](callback func() (A, B, C, D, error), fallbackA A, fallbackB B, fallbackC C, fallbackD D) (A, B, C, D, bool)
TryOr4 has the same behavior as Must, but returns a default value in case of error. Play: https://go.dev/play/p/B4F7Wg2Zh9X
func TryOr5 ¶ added in v1.29.0
func TryOr5[A, B, C, D, E any](callback func() (A, B, C, D, E, error), fallbackA A, fallbackB B, fallbackC C, fallbackD D, fallbackE E) (A, B, C, D, E, bool)
TryOr5 has the same behavior as Must, but returns a default value in case of error. Play: https://go.dev/play/p/B4F7Wg2Zh9X
func TryOr6 ¶ added in v1.29.0
func TryOr6[A, B, C, D, E, F any](callback func() (A, B, C, D, E, F, error), fallbackA A, fallbackB B, fallbackC C, fallbackD D, fallbackE E, fallbackF F) (A, B, C, D, E, F, bool)
TryOr6 has the same behavior as Must, but returns a default value in case of error. Play: https://go.dev/play/p/B4F7Wg2Zh9X
func TryWithErrorValue ¶ added in v1.11.0
TryWithErrorValue has the same behavior as Try, but also returns value passed to panic. Play: https://go.dev/play/p/Kc7afQIT2Fs
func Union ¶ added in v1.8.0
func Union[T comparable, Slice ~[]T](lists ...Slice) Slice
Union returns all distinct elements from given collections. result returns will not change the order of elements relatively.
func Uniq ¶
func Uniq[T comparable, Slice ~[]T](collection Slice) Slice
Uniq returns a duplicate-free version of an array, in which only the first occurrence of each element is kept. The order of result values is determined by the order they occur in the array. Play: https://go.dev/play/p/DTzbeXZ6iEN
func UniqBy ¶
func UniqBy[T any, U comparable, Slice ~[]T](collection Slice, iteratee func(item T) U) Slice
UniqBy returns a duplicate-free version of an array, in which only the first occurrence of each element is kept. The order of result values is determined by the order they occur in the array. It accepts `iteratee` which is invoked for each element in array to generate the criterion by which uniqueness is computed. Play: https://go.dev/play/p/g42Z3QSb53u
func UniqKeys ¶ added in v1.47.0
func UniqKeys[K comparable, V any](in ...map[K]V) []K
UniqKeys creates an array of unique keys in the map. Play: https://go.dev/play/p/TPKAb6ILdHk
func UniqMap ¶ added in v1.48.0
func UniqMap[T any, R comparable](collection []T, iteratee func(item T, index int) R) []R
UniqMap manipulates a slice and transforms it to a slice of another type with unique values.
func UniqValues ¶ added in v1.47.0
func UniqValues[K comparable, V comparable](in ...map[K]V) []V
UniqValues creates an array of unique values in the map. Play: https://go.dev/play/p/nf6bXMh7rM3
func Unpack2 ¶ added in v1.17.0
Unpack2 returns values contained in tuple. Play: https://go.dev/play/p/xVP_k0kJ96W
func Unpack3 ¶ added in v1.17.0
Unpack3 returns values contained in tuple. Play: https://go.dev/play/p/xVP_k0kJ96W
func Unpack4 ¶ added in v1.17.0
Unpack4 returns values contained in tuple. Play: https://go.dev/play/p/xVP_k0kJ96W
func Unpack5 ¶ added in v1.17.0
Unpack5 returns values contained in tuple. Play: https://go.dev/play/p/xVP_k0kJ96W
func Unpack6 ¶ added in v1.17.0
Unpack6 returns values contained in tuple. Play: https://go.dev/play/p/xVP_k0kJ96W
func Unpack7 ¶ added in v1.17.0
Unpack7 returns values contained in tuple. Play: https://go.dev/play/p/xVP_k0kJ96W
func Unpack8 ¶ added in v1.17.0
func Unpack8[A, B, C, D, E, F, G, H any](tuple Tuple8[A, B, C, D, E, F, G, H]) (A, B, C, D, E, F, G, H)
Unpack8 returns values contained in tuple. Play: https://go.dev/play/p/xVP_k0kJ96W
func Unpack9 ¶ added in v1.17.0
func Unpack9[A, B, C, D, E, F, G, H, I any](tuple Tuple9[A, B, C, D, E, F, G, H, I]) (A, B, C, D, E, F, G, H, I)
Unpack9 returns values contained in tuple. Play: https://go.dev/play/p/xVP_k0kJ96W
func Unzip2 ¶ added in v1.4.0
Unzip2 accepts an array of grouped elements and creates an array regrouping the elements to their pre-zip configuration. Play: https://go.dev/play/p/ciHugugvaAW
func Unzip3 ¶ added in v1.4.0
Unzip3 accepts an array of grouped elements and creates an array regrouping the elements to their pre-zip configuration. Play: https://go.dev/play/p/ciHugugvaAW
func Unzip4 ¶ added in v1.4.0
Unzip4 accepts an array of grouped elements and creates an array regrouping the elements to their pre-zip configuration. Play: https://go.dev/play/p/ciHugugvaAW
func Unzip5 ¶ added in v1.4.0
Unzip5 accepts an array of grouped elements and creates an array regrouping the elements to their pre-zip configuration. Play: https://go.dev/play/p/ciHugugvaAW
func Unzip6 ¶ added in v1.4.0
Unzip6 accepts an array of grouped elements and creates an array regrouping the elements to their pre-zip configuration. Play: https://go.dev/play/p/ciHugugvaAW
func Unzip7 ¶ added in v1.4.0
func Unzip7[A, B, C, D, E, F, G any](tuples []Tuple7[A, B, C, D, E, F, G]) ([]A, []B, []C, []D, []E, []F, []G)
Unzip7 accepts an array of grouped elements and creates an array regrouping the elements to their pre-zip configuration. Play: https://go.dev/play/p/ciHugugvaAW
func Unzip8 ¶ added in v1.4.0
func Unzip8[A, B, C, D, E, F, G, H any](tuples []Tuple8[A, B, C, D, E, F, G, H]) ([]A, []B, []C, []D, []E, []F, []G, []H)
Unzip8 accepts an array of grouped elements and creates an array regrouping the elements to their pre-zip configuration. Play: https://go.dev/play/p/ciHugugvaAW
func Unzip9 ¶ added in v1.4.0
func Unzip9[A, B, C, D, E, F, G, H, I any](tuples []Tuple9[A, B, C, D, E, F, G, H, I]) ([]A, []B, []C, []D, []E, []F, []G, []H, []I)
Unzip9 accepts an array of grouped elements and creates an array regrouping the elements to their pre-zip configuration. Play: https://go.dev/play/p/ciHugugvaAW
func UnzipBy2 ¶ added in v1.40.0
UnzipBy2 iterates over a collection and creates an array regrouping the elements to their pre-zip configuration.
func UnzipBy3 ¶ added in v1.40.0
func UnzipBy3[In any, A any, B any, C any](items []In, iteratee func(In) (a A, b B, c C)) ([]A, []B, []C)
UnzipBy3 iterates over a collection and creates an array regrouping the elements to their pre-zip configuration.
func UnzipBy4 ¶ added in v1.40.0
func UnzipBy4[In any, A any, B any, C any, D any](items []In, iteratee func(In) (a A, b B, c C, d D)) ([]A, []B, []C, []D)
UnzipBy4 iterates over a collection and creates an array regrouping the elements to their pre-zip configuration.
func UnzipBy5 ¶ added in v1.40.0
func UnzipBy5[In any, A any, B any, C any, D any, E any](items []In, iteratee func(In) (a A, b B, c C, d D, e E)) ([]A, []B, []C, []D, []E)
UnzipBy5 iterates over a collection and creates an array regrouping the elements to their pre-zip configuration.
func UnzipBy6 ¶ added in v1.40.0
func UnzipBy6[In any, A any, B any, C any, D any, E any, F any](items []In, iteratee func(In) (a A, b B, c C, d D, e E, f F)) ([]A, []B, []C, []D, []E, []F)
UnzipBy6 iterates over a collection and creates an array regrouping the elements to their pre-zip configuration.
func UnzipBy7 ¶ added in v1.40.0
func UnzipBy7[In any, A any, B any, C any, D any, E any, F any, G any](items []In, iteratee func(In) (a A, b B, c C, d D, e E, f F, g G)) ([]A, []B, []C, []D, []E, []F, []G)
UnzipBy7 iterates over a collection and creates an array regrouping the elements to their pre-zip configuration.
func UnzipBy8 ¶ added in v1.40.0
func UnzipBy8[In any, A any, B any, C any, D any, E any, F any, G any, H any](items []In, iteratee func(In) (a A, b B, c C, d D, e E, f F, g G, h H)) ([]A, []B, []C, []D, []E, []F, []G, []H)
UnzipBy8 iterates over a collection and creates an array regrouping the elements to their pre-zip configuration.
func UnzipBy9 ¶ added in v1.40.0
func UnzipBy9[In any, A any, B any, C any, D any, E any, F any, G any, H any, I any](items []In, iteratee func(In) (a A, b B, c C, d D, e E, f F, g G, h H, i I)) ([]A, []B, []C, []D, []E, []F, []G, []H, []I)
UnzipBy9 iterates over a collection and creates an array regrouping the elements to their pre-zip configuration.
func Validate ¶ added in v1.30.0
Validate is a helper that creates an error when a condition is not met. Play: https://go.dev/play/p/vPyh51XpCBt
func ValueOr ¶ added in v1.38.0
func ValueOr[K comparable, V any](in map[K]V, key K, fallback V) V
ValueOr returns the value of the given key or the fallback value if the key is not present. Play: https://go.dev/play/p/bAq9mHErB4V
func Values ¶
func Values[K comparable, V any](in ...map[K]V) []V
Values creates an array of the map values. Play: https://go.dev/play/p/nnRTQkzQfF6
func WaitFor ¶ added in v1.43.0
func WaitFor(condition func(i int) bool, timeout time.Duration, heartbeatDelay time.Duration) (totalIterations int, elapsed time.Duration, conditionFound bool)
WaitFor runs periodically until a condition is validated.
func WaitForWithContext ¶ added in v1.46.0
func WaitForWithContext(ctx context.Context, condition func(ctx context.Context, currentIteration int) bool, timeout time.Duration, heartbeatDelay time.Duration) (totalIterations int, elapsed time.Duration, conditionFound bool)
WaitForWithContext runs periodically until a condition is validated or context is canceled.
func Without ¶ added in v1.24.0
func Without[T comparable, Slice ~[]T](collection Slice, exclude ...T) Slice
Without returns slice excluding all given values.
func WithoutBy ¶ added in v1.48.0
func WithoutBy[T any, K comparable](collection []T, iteratee func(item T) K, exclude ...K) []T
WithoutBy filters a slice by excluding elements whose extracted keys match any in the exclude list. It returns a new slice containing only the elements whose keys are not in the exclude list.
func WithoutEmpty
deprecated
added in
v1.24.0
func WithoutEmpty[T comparable, Slice ~[]T](collection Slice) Slice
WithoutEmpty returns slice excluding zero values.
Deprecated: Use lo.Compact instead.
func WithoutNth ¶ added in v1.48.0
func WithoutNth[T comparable, Slice ~[]T](collection Slice, nths ...int) Slice
WithoutNth returns slice excluding nth value.
func ZipBy2 ¶ added in v1.40.0
ZipBy2 creates a slice of transformed elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on. When collections have different size, the Tuple attributes are filled with zero value.
func ZipBy3 ¶ added in v1.40.0
func ZipBy3[A any, B any, C any, Out any](a []A, b []B, c []C, iteratee func(a A, b B, c C) Out) []Out
ZipBy3 creates a slice of transformed elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on. When collections have different size, the Tuple attributes are filled with zero value.
func ZipBy4 ¶ added in v1.40.0
func ZipBy4[A any, B any, C any, D any, Out any](a []A, b []B, c []C, d []D, iteratee func(a A, b B, c C, d D) Out) []Out
ZipBy4 creates a slice of transformed elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on. When collections have different size, the Tuple attributes are filled with zero value.
func ZipBy5 ¶ added in v1.40.0
func ZipBy5[A any, B any, C any, D any, E any, Out any](a []A, b []B, c []C, d []D, e []E, iteratee func(a A, b B, c C, d D, e E) Out) []Out
ZipBy5 creates a slice of transformed elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on. When collections have different size, the Tuple attributes are filled with zero value.
func ZipBy6 ¶ added in v1.40.0
func ZipBy6[A any, B any, C any, D any, E any, F any, Out any](a []A, b []B, c []C, d []D, e []E, f []F, iteratee func(a A, b B, c C, d D, e E, f F) Out) []Out
ZipBy6 creates a slice of transformed elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on. When collections have different size, the Tuple attributes are filled with zero value.
func ZipBy7 ¶ added in v1.40.0
func ZipBy7[A any, B any, C any, D any, E any, F any, G any, Out any](a []A, b []B, c []C, d []D, e []E, f []F, g []G, iteratee func(a A, b B, c C, d D, e E, f F, g G) Out) []Out
ZipBy7 creates a slice of transformed elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on. When collections have different size, the Tuple attributes are filled with zero value.
func ZipBy8 ¶ added in v1.40.0
func ZipBy8[A any, B any, C any, D any, E any, F any, G any, H any, Out any](a []A, b []B, c []C, d []D, e []E, f []F, g []G, h []H, iteratee func(a A, b B, c C, d D, e E, f F, g G, h H) Out) []Out
ZipBy8 creates a slice of transformed elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on. When collections have different size, the Tuple attributes are filled with zero value.
func ZipBy9 ¶ added in v1.40.0
func ZipBy9[A any, B any, C any, D any, E any, F any, G any, H any, I any, Out any](a []A, b []B, c []C, d []D, e []E, f []F, g []G, h []H, i []I, iteratee func(a A, b B, c C, d D, e E, f F, g G, h H, i I) Out) []Out
ZipBy9 creates a slice of transformed elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on. When collections have different size, the Tuple attributes are filled with zero value.
Types ¶
type Clonable ¶
type Clonable[T any] interface { Clone() T }
Clonable defines a constraint of types having Clone() T method.
type DispatchingStrategy ¶ added in v1.28.0
func DispatchingStrategyWeightedRandom ¶ added in v1.28.0
func DispatchingStrategyWeightedRandom[T any](weights []int) DispatchingStrategy[T]
DispatchingStrategyWeightedRandom distributes messages in a weighted manner. If the channel capacity is exceeded, another random channel will be selected and so on.
type Entry ¶
type Entry[K comparable, V any] struct { Key K Value V }
Entry defines a key/value pairs.
func Entries ¶
func Entries[K comparable, V any](in map[K]V) []Entry[K, V]
Entries transforms a map into array of key/value pairs. Play:
func ToPairs ¶ added in v1.22.0
func ToPairs[K comparable, V any](in map[K]V) []Entry[K, V]
ToPairs transforms a map into array of key/value pairs. Alias of Entries(). Play: https://go.dev/play/p/3Dhgx46gawJ
type Transaction ¶ added in v1.37.0
type Transaction[T any] struct { // contains filtered or unexported fields }
Transaction implements a Saga pattern
func NewTransaction ¶ added in v1.37.0
func NewTransaction[T any]() *Transaction[T]
NewTransaction instantiate a new transaction.
func (*Transaction[T]) Process ¶ added in v1.37.0
func (t *Transaction[T]) Process(state T) (T, error)
Process runs the Transaction steps and rollbacks in case of errors.
func (*Transaction[T]) Then ¶ added in v1.37.0
func (t *Transaction[T]) Then(exec func(T) (T, error), onRollback func(T) T) *Transaction[T]
Then adds a step to the chain of callbacks. It returns the same Transaction.
type Tuple2 ¶ added in v1.4.0
type Tuple2[A, B any] struct { A A B B }
Tuple2 is a group of 2 elements (pair).
func CrossJoin2 ¶ added in v1.48.0
CrossJoin2 combines every items from one list with every items from others. It is the cartesian product of lists received as arguments. It returns an empty list if a list is empty.
func T2 ¶ added in v1.13.0
T2 creates a tuple from a list of values. Play: https://go.dev/play/p/IllL3ZO4BQm
func Zip2 ¶ added in v1.4.0
Zip2 creates a slice of grouped elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on. When collections have different size, the Tuple attributes are filled with zero value. Play: https://go.dev/play/p/jujaA6GaJTp
type Tuple3 ¶ added in v1.4.0
type Tuple3[A, B, C any] struct { A A B B C C }
Tuple3 is a group of 3 elements.
func CrossJoin3 ¶ added in v1.48.0
CrossJoin3 combines every items from one list with every items from others. It is the cartesian product of lists received as arguments. It returns an empty list if a list is empty.
func T3 ¶ added in v1.13.0
T3 creates a tuple from a list of values. Play: https://go.dev/play/p/IllL3ZO4BQm
func Zip3 ¶ added in v1.4.0
Zip3 creates a slice of grouped elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on. When collections have different size, the Tuple attributes are filled with zero value. Play: https://go.dev/play/p/jujaA6GaJTp
type Tuple4 ¶ added in v1.4.0
type Tuple4[A, B, C, D any] struct { A A B B C C D D }
Tuple4 is a group of 4 elements.
func CrossJoin4 ¶ added in v1.48.0
CrossJoin4 combines every items from one list with every items from others. It is the cartesian product of lists received as arguments. It returns an empty list if a list is empty.
func T4 ¶ added in v1.13.0
T4 creates a tuple from a list of values. Play: https://go.dev/play/p/IllL3ZO4BQm
func Zip4 ¶ added in v1.4.0
Zip4 creates a slice of grouped elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on. When collections have different size, the Tuple attributes are filled with zero value. Play: https://go.dev/play/p/jujaA6GaJTp
type Tuple5 ¶ added in v1.4.0
type Tuple5[A, B, C, D, E any] struct { A A B B C C D D E E }
Tuple5 is a group of 5 elements.
func CrossJoin5 ¶ added in v1.48.0
func CrossJoin5[A, B, C, D, E any](listA []A, listB []B, listC []C, listD []D, listE []E) []Tuple5[A, B, C, D, E]
CrossJoin5 combines every items from one list with every items from others. It is the cartesian product of lists received as arguments. It returns an empty list if a list is empty.
func T5 ¶ added in v1.13.0
T5 creates a tuple from a list of values. Play: https://go.dev/play/p/IllL3ZO4BQm
func Zip5 ¶ added in v1.4.0
Zip5 creates a slice of grouped elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on. When collections have different size, the Tuple attributes are filled with zero value. Play: https://go.dev/play/p/jujaA6GaJTp
type Tuple6 ¶ added in v1.4.0
type Tuple6[A, B, C, D, E, F any] struct { A A B B C C D D E E F F }
Tuple6 is a group of 6 elements.
func CrossJoin6 ¶ added in v1.48.0
func CrossJoin6[A, B, C, D, E, F any](listA []A, listB []B, listC []C, listD []D, listE []E, listF []F) []Tuple6[A, B, C, D, E, F]
CrossJoin6 combines every items from one list with every items from others. It is the cartesian product of lists received as arguments. It returns an empty list if a list is empty.
func T6 ¶ added in v1.13.0
T6 creates a tuple from a list of values. Play: https://go.dev/play/p/IllL3ZO4BQm
func Zip6 ¶ added in v1.4.0
func Zip6[A, B, C, D, E, F any](a []A, b []B, c []C, d []D, e []E, f []F) []Tuple6[A, B, C, D, E, F]
Zip6 creates a slice of grouped elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on. When collections have different size, the Tuple attributes are filled with zero value. Play: https://go.dev/play/p/jujaA6GaJTp
type Tuple7 ¶ added in v1.4.0
type Tuple7[A, B, C, D, E, F, G any] struct { A A B B C C D D E E F F G G }
Tuple7 is a group of 7 elements.
func CrossJoin7 ¶ added in v1.48.0
func CrossJoin7[A, B, C, D, E, F, G any](listA []A, listB []B, listC []C, listD []D, listE []E, listF []F, listG []G) []Tuple7[A, B, C, D, E, F, G]
CrossJoin7 combines every items from one list with every items from others. It is the cartesian product of lists received as arguments. It returns an empty list if a list is empty.
func T7 ¶ added in v1.13.0
T7 creates a tuple from a list of values. Play: https://go.dev/play/p/IllL3ZO4BQm
func Zip7 ¶ added in v1.4.0
func Zip7[A, B, C, D, E, F, G any](a []A, b []B, c []C, d []D, e []E, f []F, g []G) []Tuple7[A, B, C, D, E, F, G]
Zip7 creates a slice of grouped elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on. When collections have different size, the Tuple attributes are filled with zero value. Play: https://go.dev/play/p/jujaA6GaJTp
type Tuple8 ¶ added in v1.4.0
type Tuple8[A, B, C, D, E, F, G, H any] struct { A A B B C C D D E E F F G G H H }
Tuple8 is a group of 8 elements.
func CrossJoin8 ¶ added in v1.48.0
func CrossJoin8[A, B, C, D, E, F, G, H any](listA []A, listB []B, listC []C, listD []D, listE []E, listF []F, listG []G, listH []H) []Tuple8[A, B, C, D, E, F, G, H]
CrossJoin8 combines every items from one list with every items from others. It is the cartesian product of lists received as arguments. It returns an empty list if a list is empty.
func T8 ¶ added in v1.13.0
func T8[A, B, C, D, E, F, G, H any](a A, b B, c C, d D, e E, f F, g G, h H) Tuple8[A, B, C, D, E, F, G, H]
T8 creates a tuple from a list of values. Play: https://go.dev/play/p/IllL3ZO4BQm
func Zip8 ¶ added in v1.4.0
func Zip8[A, B, C, D, E, F, G, H any](a []A, b []B, c []C, d []D, e []E, f []F, g []G, h []H) []Tuple8[A, B, C, D, E, F, G, H]
Zip8 creates a slice of grouped elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on. When collections have different size, the Tuple attributes are filled with zero value. Play: https://go.dev/play/p/jujaA6GaJTp
type Tuple9 ¶ added in v1.4.0
type Tuple9[A, B, C, D, E, F, G, H, I any] struct { A A B B C C D D E E F F G G H H I I }
Tuple9 is a group of 9 elements.
func CrossJoin9 ¶ added in v1.48.0
func CrossJoin9[A, B, C, D, E, F, G, H, I any](listA []A, listB []B, listC []C, listD []D, listE []E, listF []F, listG []G, listH []H, listI []I) []Tuple9[A, B, C, D, E, F, G, H, I]
CrossJoin9 combines every items from one list with every items from others. It is the cartesian product of lists received as arguments. It returns an empty list if a list is empty.
func T9 ¶ added in v1.13.0
func T9[A, B, C, D, E, F, G, H, I any](a A, b B, c C, d D, e E, f F, g G, h H, i I) Tuple9[A, B, C, D, E, F, G, H, I]
T9 creates a tuple from a list of values. Play: https://go.dev/play/p/IllL3ZO4BQm
func Zip9 ¶ added in v1.4.0
func Zip9[A, B, C, D, E, F, G, H, I any](a []A, b []B, c []C, d []D, e []E, f []F, g []G, h []H, i []I) []Tuple9[A, B, C, D, E, F, G, H, I]
Zip9 creates a slice of grouped elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on. When collections have different size, the Tuple attributes are filled with zero value. Play: https://go.dev/play/p/jujaA6GaJTp
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
internal
|
|
constraints
Package constraints defines a set of useful constraints to be used with type parameters.
|
Package constraints defines a set of useful constraints to be used with type parameters. |