slicer

package
v0.0.0-...-21c6822 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AToInterfaces

func AToInterfaces[S ~[]E, E any](s S) []interface{}

func AToStrings

func AToStrings[S ~[]E, E any](s S) []string

func AddIfNotFound

func AddIfNotFound[S []E, E any](s S, f func(E) bool, e E) S

func CleanEmptyStrings

func CleanEmptyStrings(s []string) []string

func ContainsF

func ContainsF[S ~[]E, E any](s S, f func(E) bool) bool

ContainsF checks if the given function returns true for any element in the slice.

func ContainsStr

func ContainsStr(s []string, e string) bool

func Each

func Each[S ~[]E, E any](s S, f func(E))

func Filter

func Filter[S ~[]E, E any](s S, f func(E) bool) []E

func Find

func Find[S ~[]E, E any](s S, f func(E) bool) (int, E)

func FindAndDo

func FindAndDo[S ~[]E, E any](s S, f func(E) bool, do func(int, E))

func FindMaxByTimeF

func FindMaxByTimeF[S ~[]E, E comparable](s S, f func(E) time.Time) E

func FindMinByTimeF

func FindMinByTimeF[S ~[]E, E comparable](s S, f func(E) time.Time) E

func First

func First[S ~[]E, E any](s S) E

func GetFieldValue

func GetFieldValue(s interface{}, fieldName string) (interface{}, bool)

GetFieldValue gets the value of a struct field by its name

func GetFieldValueRecursive

func GetFieldValueRecursive(s interface{}, fieldNames []string) (interface{}, bool)

GetFieldValueRecursive retrieves the value of a struct field, potentially nested within multiple levels of structs. It handles pointers and returns the found value or nil if not found.

func Group

func Group[S ~[]E, E any, K comparable](s S, f func(E) K) map[K]S

Group groups the elements of a collection by a specified key.

func Includes

func Includes[S ~[]E, E any](s S, e E) bool

func Increment

func Increment[S ~[]E, E any](s S, f func(E) bool) int

func IsLastIndex

func IsLastIndex[E any](i int, s []E) bool

func Join

func Join[E any](s []E, sep string) string

func Last

func Last[S ~[]E, E any](s S) E

func LastIndexOf

func LastIndexOf[E any](s []E) int

func Map

func Map[S ~[]E, E any, T any](s S, f func(E) T) []T

func Merge

func Merge[S ~[]E, S2 ~[]E, E any](s1 S, s2 S2) []E

func MergeF

func MergeF[S ~[]E, S2 ~[]E2, E any, E2 any](s1 S, s2 S2, f func(E2) E) []E

func Order

func Order[S ~[]E, E any](s S, f func(E, E) bool)

func Pluck

func Pluck[S ~[]E, E any, K comparable](s S, f func(E) K) []K

func PluckByField

func PluckByField[S ~[]E, E any](s S, fieldName string) []interface{}

func Reduce

func Reduce[S ~[]E, E any, V any](s S, f func(V, E) V, initialValue V) V

func SumF

func SumF[S ~[]E, E any, T constraints.Signed | constraints.Unsigned | ~float32 | ~float64](s S, f func(E) T) T

func Unique

func Unique[S ~[]E, E comparable](s S) []E

func UniqueF

func UniqueF[S ~[]E, E any, K comparable](s S, f func(E) K) []E

Types

This section is empty.

Jump to

Keyboard shortcuts

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