Documentation ¶
Index ¶
- func Batch[T any, V any](fn func(T) V, ts []T) []V
- func Between[E Ordered](data, left, right E) bool
- func BetweenEq[E Ordered](data, left, right E) bool
- func BetweenLEq[E Ordered](data, left, right E) bool
- func BetweenREq[E Ordered](data, left, right E) bool
- func BothExist[E comparable](es ...[]E) []E
- func BothExistAny[E any, K comparable](es [][]E, fn func(e E) K) []E
- func Complete[E comparable](a []E, b []E) bool
- func Contain[E comparable](e E, es ...E) bool
- func CopySlice[T any](a []T) []T
- func CopyStructFields(a any, b any, fields ...string) (err error)
- func Delete[E any](es []E, index ...int) []E
- func DeleteAt[E any](es *[]E, index ...int) []E
- func DeleteElems[E comparable](es []E, delEs ...E) []E
- func Distinct[T comparable](ts []T) []T
- func DistinctAny[E any, K comparable](es []E, fn func(e E) K) []E
- func DistinctAnyGetComparable[E any, K comparable](es []E, fn func(e E) K) []K
- func Duplicate[E comparable](es []E) bool
- func DuplicateAny[E any, K comparable](es []E, fn func(e E) K) bool
- func Equal[E comparable](a []E, b []E) bool
- func Filter[E, T any](es []E, fn func(e E) (T, bool)) []T
- func GetElemByIndex(array []int, index int) (int, error)
- func GetSwitchFromOptions(Options map[string]bool, key string) (result bool)
- func HasKey[K comparable, V any](m map[K]V, k K) bool
- func If[T any](isa bool, a, b T) T
- func IndexAny[E any, K comparable](e E, es []E, fn func(e E) K) int
- func IndexOf[E comparable](e E, es ...E) int
- func InitMap[K comparable, V any](val *map[K]V)
- func InitSlice[T any](val *[]T)
- func Keys[K comparable, V any](kv map[K]V) []K
- func Max[E Ordered](e ...E) E
- func Min[E Ordered](e ...E) E
- func NotNilReplace[T any](old, new_ *T)
- func Order[E comparable, T any](es []E, ts []T, fn func(t T) E) []T
- func OrderPtr[E comparable, T any](es []E, ts *[]T, fn func(t T) E) []T
- func Paginate[E any](es []E, pageNumber int, showNumber int) []E
- func SetSwitchFromOptions(options map[string]bool, key string, value bool)
- func ShuffleSlice[T any](a []T) []T
- func Single[E comparable](a, b []E) []E
- func Slice[E any, T any](es []E, fn func(e E) T) []T
- func SliceAnySub[E any, T comparable](a, b []E, fn func(t E) T) []E
- func SlicePaginate[E any](es []E, pagination pagination.Pagination) []E
- func SliceSet[E comparable](es []E) map[E]struct{}
- func SliceSetAny[E any, K comparable](es []E, fn func(e E) K) map[K]struct{}
- func SliceSub[E comparable](a, b []E) []E
- func SliceSubAny[E comparable, T any](a []E, b []T, fn func(t T) E) []E
- func SliceSubConvertPre[E comparable, T any](a []T, b []E, fn func(t T) E) []T
- func SliceSubFunc[T any, E comparable](a, b []T, fn func(i T) E) []T
- func SliceSubFuncs[T, V any, E comparable](a []T, b []V, fna func(i T) E, fnb func(i V) E) []T
- func SliceToMap[E any, K comparable](es []E, fn func(e E) K) map[K]E
- func SliceToMapAny[E any, K comparable, V any](es []E, fn func(e E) (K, V)) map[K]V
- func SliceToMapOkAny[E any, K comparable, V any](es []E, fn func(e E) (K, V, bool)) map[K]V
- func Sort[E Ordered](es []E, asc bool) []E
- func SortAny[E any](es []E, fn func(a, b E) bool)
- func StructFieldNotNilReplace(dest, src any)
- func ToPtr[T any](t T) *T
- func UniqueJoin(s ...string) string
- func Values[K comparable, V any](kv map[K]V) []V
- type Ordered
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Between ¶ added in v0.0.49
Between checks if data is between left and right, excluding equality.
func BetweenEq ¶ added in v0.0.49
BetweenEq checks if data is between left and right, including equality.
func BetweenLEq ¶ added in v0.0.49
BetweenLEq checks if data is between left and right, including left equality.
func BetweenREq ¶ added in v0.0.49
BetweenREq checks if data is between left and right, including right equality.
func BothExist ¶
func BothExist[E comparable](es ...[]E) []E
BothExist Gets the common elements in the slice (intersection)
func BothExistAny ¶
func BothExistAny[E any, K comparable](es [][]E, fn func(e E) K) []E
BothExistAny gets elements that are common in the slice (intersection)
func Complete ¶
func Complete[E comparable](a []E, b []E) bool
Complete whether a and b are equal after deduplication (ignore order)
func CopyStructFields ¶
copy a by b b->a
func DeleteAt ¶
DeleteAt Delete slice elements, support negative number to delete the reciprocal number
func DeleteElems ¶ added in v0.0.49
func DeleteElems[E comparable](es []E, delEs ...E) []E
DeleteElems delete elems in slice.
func Distinct ¶
func Distinct[T comparable](ts []T) []T
func DistinctAny ¶
func DistinctAny[E any, K comparable](es []E, fn func(e E) K) []E
DistinctAny duplicate removal.
func DistinctAnyGetComparable ¶
func DistinctAnyGetComparable[E any, K comparable](es []E, fn func(e E) K) []K
func DuplicateAny ¶
func DuplicateAny[E any, K comparable](es []E, fn func(e E) K) bool
DuplicateAny Whether there are duplicates
func Equal ¶
func Equal[E comparable](a []E, b []E) bool
Equal Compares slices to each other (including element order)
func GetSwitchFromOptions ¶
func HasKey ¶
func HasKey[K comparable, V any](m map[K]V, k K) bool
HasKey get whether the map contains key
func IndexAny ¶
func IndexAny[E any, K comparable](e E, es []E, fn func(e E) K) int
IndexAny get the index of the element
func InitMap ¶
func InitMap[K comparable, V any](val *map[K]V)
func NotNilReplace ¶
func NotNilReplace[T any](old, new_ *T)
NotNilReplace sets old to new_ when new_ is not null
func Order ¶
func Order[E comparable, T any](es []E, ts []T, fn func(t T) E) []T
Order sorts ts by es
func OrderPtr ¶
func OrderPtr[E comparable, T any](es []E, ts *[]T, fn func(t T) E) []T
func SetSwitchFromOptions ¶
func ShuffleSlice ¶
func ShuffleSlice[T any](a []T) []T
func Single ¶
func Single[E comparable](a, b []E) []E
Single exists in a and does not exist in b or exists in b and does not exist in a
func SliceAnySub ¶
func SliceAnySub[E any, T comparable](a, b []E, fn func(t E) T) []E
SliceAnySub returns elements in slice a that are not present in slice b (a - b).
func SlicePaginate ¶ added in v0.0.49
func SlicePaginate[E any](es []E, pagination pagination.Pagination) []E
func SliceSetAny ¶
func SliceSetAny[E any, K comparable](es []E, fn func(e E) K) map[K]struct{}
SliceSetAny slice to map[K]struct{}
func SliceSub ¶
func SliceSub[E comparable](a, b []E) []E
SliceSub returns elements in slice a that are not present in slice b (a - b) and remove duplicates.
func SliceSubAny ¶
func SliceSubAny[E comparable, T any](a []E, b []T, fn func(t T) E) []E
SliceSubAny returns elements in slice a that are not present in slice b (a - b) and remove duplicates. fn is a function that converts elements of slice b to elements comparable with those in slice a.
func SliceSubConvertPre ¶ added in v0.0.49
func SliceSubConvertPre[E comparable, T any](a []T, b []E, fn func(t T) E) []T
SliceSubConvertPre returns elements in slice a that are not present in slice b (a - b) and remove duplicates. fn is a function that converts elements of slice a to elements comparable with those in slice b.
func SliceSubFunc ¶ added in v0.0.49
func SliceSubFunc[T any, E comparable](a, b []T, fn func(i T) E) []T
SliceSubFunc returns elements in slice a that are not present in slice b (a - b) and remove duplicates. Determine if elements are equal based on the result returned by fn.
func SliceSubFuncs ¶ added in v0.0.49
func SliceSubFuncs[T, V any, E comparable](a []T, b []V, fna func(i T) E, fnb func(i V) E) []T
SliceSubFuncs returns elements in slice a that are not present in slice b (a - b) and remove duplicates. Determine if elements are equal based on the result returned by fna(a[i]) and fnb(b[i]).
func SliceToMap ¶
func SliceToMap[E any, K comparable](es []E, fn func(e E) K) map[K]E
SliceToMap slice to map
func SliceToMapAny ¶
func SliceToMapAny[E any, K comparable, V any](es []E, fn func(e E) (K, V)) map[K]V
SliceToMapAny slice to map (Custom type)
func SliceToMapOkAny ¶
func SliceToMapOkAny[E any, K comparable, V any](es []E, fn func(e E) (K, V, bool)) map[K]V
SliceToMapOkAny slice to map (Custom type, filter)
func StructFieldNotNilReplace ¶
func StructFieldNotNilReplace(dest, src any)