Documentation ¶
Index ¶
- func ArrayCast[T any](source []interface{}) []T
- func ArrayConvert[T any, Y any](source []Y, convert func(item Y) T) []T
- func ArrayFilter[T any](source []T, filter func(item T) bool) []T
- func Average(source []float64) float64
- func If[T any](cond bool, vtrue, vfalse T) T
- func IfNillable[T any](cond bool, vtrueNillable func() T, vfalse T) T
- func Max(source []float64) float64
- func Random(max, min int) int
- func RandomID(name string) string
- func RandomItemFromArray[X any](source []X) X
- func SplitSlice[T any, Y comparable](source []T, identification func(item T) Y) (m map[Y][]T)
- func SplitString(source, delimiter string) []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArrayConvert ¶
func ArrayFilter ¶
func IfNillable ¶ added in v0.6.9
In case vtrue value depends on a variable checked on condition which could be nil as params are evaluated within the If function invokation it will produce a panic error in that case we will pass the vtrue as a function which will be evaluated only if condition is met
i.e. If(foo != nil, foo.bar, "") In this case if foo is nill this will error with panic as the evaluation will try access foo which is nil
so, in this case we will use IfNillable: bar = func() { return foo.bar} IfNillable(foo != nil, bar, "")
func RandomItemFromArray ¶
func RandomItemFromArray[X any](source []X) X
func SplitSlice ¶
func SplitSlice[T any, Y comparable](source []T, identification func(item T) Y) (m map[Y][]T)
This function split a list based on a evaluation function the result is a map of lists
func SplitString ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.