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 IfWithError[T any](cond bool, vtrue, vfalse func() (T, error)) (T, error)
- func Max(source []float64) float64
- func Random(max, min int) int
- func RandomID(name string) string
- func RandomItemFromArray[X any](source []X) X
- func SplitString(source, delimiter string) []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArrayConvert ¶
func ArrayFilter ¶
Return a new array list with those items from source which return true from filter function
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 IfWithError ¶ added in v0.9.0
func RandomItemFromArray ¶
func RandomItemFromArray[X any](source []X) X
func SplitString ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.