Documentation
¶
Index ¶
- func ApplyOptions[C any, F ~func(*C)](cfg *C, opts ...F) *C
- func BuildConfig[C any, F ~func(*C)](opts []F) *C
- func Cast[T any](origin any) (T, bool)
- func CastInto[T any](origin any, into *T) bool
- func Default[T any](v *T, d T) T
- func EnsureRange(min, max int64) (int64, int64)
- func Find[T any](arr []T, predicate func(T) bool) (out *T)
- func FindIdx[T any](arr []T, predicate func(T) bool) (*T, int)
- func FindIdxIter[T any](it iter.Seq[T], predicate func(T) bool) (*T, int)
- func FindIter[T any](it iter.Seq[T], predicate func(T) bool) (out *T)
- func First[T any](a T, _ ...any) T
- func ForEach[T any](arr []T, clb func(T))
- func NewAtomicPtr[T any](v *T) atomic.Pointer[T]
- func NonBlockingSend[T any](c chan T, el T)
- func Or[T comparable](a, b T) (zero T)
- func ParallelForEach[T any](ctx context.Context, s iter.Seq[T], workerCount int, fn func(T))
- func Ptr[T any](v T) *T
- func RandDuration(min, max time.Duration) time.Duration
- func Random(min, max int64) (out int64)
- func RandomFrom(r *rand.Rand, min, max int64) int64
- func Second[T any](_ any, a T, _ ...any) T
- func ShortDur(v any) string
- func SliceSeq[T any](s []T) iter.Seq[T]
- func Some[T any](arr []T, predicate func(T) bool) bool
- func SomeIter[T any](it iter.Seq[T], predicate func(T) bool) bool
- func Ternary[T any](predicate bool, a, b T) T
- func TernaryOrZero[T any](predicate bool, a T) (zero T)
- func TryCast[T any](origin any) bool
- func UuidV4() (uuid [16]byte)
- func UuidV4Str() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Default ¶
func Default[T any](v *T, d T) T
Default return the value of "v" if not nil, otherwise return the default "d" value
func EnsureRange ¶
EnsureRange ensure min is smaller or equal to max
func Find ¶
Find looks through each value in the list, returning the first one that passes a truth test (predicate), or nil if no value passes the test. The function returns as soon as it finds an acceptable element, and doesn't traverse the entire list
func FindIdxIter ¶
FindIdxIter ...
func ParallelForEach ¶
ParallelForEach ...
func RandDuration ¶
RandDuration generates random duration
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.