Documentation
¶
Index ¶
- Variables
- func Any[T any](v T) any
- func AssertNil[T any](v T, terminator ...delegate.Action) bool
- func AssertNotNil[T any](v T, terminator ...delegate.Action) bool
- func AssertType[TAssert, TVal any](v TVal, terminator ...delegate.Action) bool
- func AssertZeroVal[T comparable](v T, terminator ...delegate.Action) bool
- func Between[T constraints.Ordered](v T, begin, end T) bool
- func ConvI2I64Any(val any) (int64, error)
- func Convert[T any](val any, defaultV T) (T, error)
- func ConvertMust[T any](val any) T
- func DoAsSlice[T any](input any, cb func(val T) error) error
- func Flatten2DSlice(input any) ([]any, error)
- func Flatten2DSliceGeneric[T any](input ...[]T) []T
- func FlattenNestedSlices(input any, depth int) []any
- func I2Str[T constraints.Integer](num T) string
- func IfThen[T any](cond bool, a T, b T) T
- func Is2DSlice(v any) bool
- func IsNil(v any) bool
- func IsNotNil(v any) bool
- func IsSlice(v any) bool
- func IsType[TAssert, TVal any](v TVal) bool
- func IsZero[T comparable](v T) bool
- func KVs[TKey comparable, TVal any](m map[TKey]TVal) []struct{ ... }
- func Keys[TKey comparable, TVal any](m map[TKey]TVal) []TKey
- func KeysSorted[TKey constraints.Ordered, TVal any](m map[TKey]TVal) []TKey
- func MapDump[TKey comparable, TVal any](m map[TKey]TVal, dumper delegate.Func2[TKey, TVal, string]) []string
- func MapForEachOrderly[TKey constraints.Ordered, TVal any](m map[TKey]TVal, traver func(key TKey, val TVal))
- func MapMap[TKey comparable, TVal any, TKey1 comparable, TVal1 any](m map[TKey]TVal, keyConv delegate.Convert[TKey, TKey1], ...) map[TKey1]TVal1
- func Or[T comparable](a, b T) T
- func PanicWhenError(err error, fmtOrMsg string, args ...any)
- func Ptr[T any](v T) *T
- func S2IMust[T constraints.Integer](str string) T
- func SliceContains[TVal comparable](slice []TVal, val TVal) bool
- func SliceDiff[TSliceVal comparable](oldLst, newLst []TSliceVal) (toAdd, toRemove []TSliceVal)
- func SliceFilter[TVal comparable](slice []TVal, pred delegate.Predicate[TVal]) []TVal
- func SliceFirst[TVal comparable](slice []TVal, val TVal) int
- func SliceFirstMatch[TVal comparable](slice []TVal, pred delegate.Predicate[TVal]) int
- func SliceForeach[TSliceVal any](slice []TSliceVal, foreachFn delegate.Action1[TSliceVal])
- func SliceForeachI[TSliceVal any](slice []TSliceVal, foreachFn delegate.Action2[TSliceVal, int])
- func SliceLast[TSliceVal any](slice []TSliceVal) TSliceVal
- func SliceMap[TFrom, TTo any](from []TFrom, mapFn delegate.Convert[TFrom, TTo]) []TTo
- func SliceMax[TSliceVal constraints.Ordered](data []TSliceVal) (ret TSliceVal)
- func SliceMin[TSliceVal constraints.Ordered](data []TSliceVal) (ret TSliceVal)
- func SlicePadRight[TSliceVal any](slice []TSliceVal, length int, padVal TSliceVal) []TSliceVal
- func SliceRand[TVal comparable](slice []TVal, defaultVal TVal) TVal
- func SliceReduce[TSliceVal, TTarget any](slice []TSliceVal, reduceFn func(TSliceVal, TTarget) TTarget, ...) TTarget
- func SliceReverse[TSliceVal any](data []TSliceVal)
- func SliceSort[TSliceVal constraints.Ordered](slice []TSliceVal)
- func SliceToTrueMap[TSliceVal comparable](list []TSliceVal) map[TSliceVal]struct{}
- func SliceTryGet[TSliceVal any](slice []TSliceVal, i int, defaultVal TSliceVal) TSliceVal
- func Str[T any](v T) string
- func Vals[TKey comparable, TVal any](m map[TKey]TVal) []TVal
- func ZeroVal[T any]() (v T)
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrPropertyType = errors.New("got/typer: convert type failed")
Functions ¶
func AssertZeroVal ¶
func AssertZeroVal[T comparable](v T, terminator ...delegate.Action) bool
func Between ¶
func Between[T constraints.Ordered](v T, begin, end T) bool
func ConvI2I64Any ¶
func ConvertMust ¶
func Flatten2DSlice ¶
Flatten2DSlice flattens a 2D array into a 1D array.
func Flatten2DSliceGeneric ¶
func Flatten2DSliceGeneric[T any](input ...[]T) []T
Flatten2DSliceGeneric flattens a 2D array of type T into a 1D array.
func FlattenNestedSlices ¶
FlattenNestedSlices flattens nested slices or arrays into a single-dimensional slice.
It takes two parameters:
- input: the input data of any type, which may contain nested slices or arrays.
- depth: the target flattening depth, controlling the number of levels to flatten.
If the target depth is 0, no flattening is performed, and the input is returned as a slice.
The function recursively flattens the input data up to the specified depth. If the current depth reaches the target depth, the elements are added to the result slice without further flattening.
It returns a []any slice containing the flattened elements.
func I2Str ¶
func I2Str[T constraints.Integer](num T) string
func IsZero ¶
func IsZero[T comparable](v T) bool
func KVs ¶
func KVs[TKey comparable, TVal any](m map[TKey]TVal) []struct { Key TKey Val TVal }
func Keys ¶
func Keys[TKey comparable, TVal any](m map[TKey]TVal) []TKey
func KeysSorted ¶
func KeysSorted[TKey constraints.Ordered, TVal any](m map[TKey]TVal) []TKey
func MapForEachOrderly ¶
func MapForEachOrderly[TKey constraints.Ordered, TVal any](m map[TKey]TVal, traver func(key TKey, val TVal))
func MapMap ¶
func MapMap[TKey comparable, TVal any, TKey1 comparable, TVal1 any](m map[TKey]TVal, keyConv delegate.Convert[TKey, TKey1], valConv delegate.Convert[TVal, TVal1]) map[TKey1]TVal1
func Or ¶
func Or[T comparable](a, b T) T
func PanicWhenError ¶
func S2IMust ¶
func S2IMust[T constraints.Integer](str string) T
func SliceContains ¶
func SliceContains[TVal comparable](slice []TVal, val TVal) bool
func SliceDiff ¶
func SliceDiff[TSliceVal comparable](oldLst, newLst []TSliceVal) (toAdd, toRemove []TSliceVal)
func SliceFilter ¶
func SliceFilter[TVal comparable](slice []TVal, pred delegate.Predicate[TVal]) []TVal
func SliceFirst ¶
func SliceFirst[TVal comparable](slice []TVal, val TVal) int
func SliceFirstMatch ¶
func SliceFirstMatch[TVal comparable](slice []TVal, pred delegate.Predicate[TVal]) int
func SliceForeach ¶
func SliceForeachI ¶
func SliceMax ¶
func SliceMax[TSliceVal constraints.Ordered](data []TSliceVal) (ret TSliceVal)
func SliceMin ¶
func SliceMin[TSliceVal constraints.Ordered](data []TSliceVal) (ret TSliceVal)
func SlicePadRight ¶
func SliceRand ¶
func SliceRand[TVal comparable](slice []TVal, defaultVal TVal) TVal
func SliceReduce ¶
func SliceReduce[TSliceVal, TTarget any](slice []TSliceVal, reduceFn func(TSliceVal, TTarget) TTarget, defaultVal TTarget) TTarget
func SliceReverse ¶
func SliceReverse[TSliceVal any](data []TSliceVal)
func SliceSort ¶
func SliceSort[TSliceVal constraints.Ordered](slice []TSliceVal)
func SliceToTrueMap ¶
func SliceToTrueMap[TSliceVal comparable](list []TSliceVal) map[TSliceVal]struct{}
func SliceTryGet ¶
func Vals ¶
func Vals[TKey comparable, TVal any](m map[TKey]TVal) []TVal
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.