Documentation ¶
Index ¶
- func IterateInterfaceAsMap(a interface{}, onIterate func(k, v interface{}))
- func IterateInterfaceAsSlice(a interface{}, onIterate func(iterItem interface{}) (keepIterate bool))
- func Map2Strings(a interface{}, fn func(k, v interface{}) string) (ret []string)
- func Slice2Strings(a interface{}, fn func(originItem interface{}) string) (ret []string)
- func Slice2Times(a interface{}, fn func(originItem interface{}) time.Time) (ret []time.Time)
- func SliceAllOf(a interface{}, fn func(originItem interface{}) bool) (ret bool)
- func SliceLimit(a interface{}, PrefixNumLimit int, SuffixNumLimit int, cb func(index int))
- func SliceMax(a interface{}, less func(i, j int) bool) (max interface{})
- func SliceMinMax(a interface{}, less func(i, j int) bool) (min, max interface{})
- func SliceUniqueCount(a interface{}, fn func(originItem interface{}) string) (ret map[string]int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IterateInterfaceAsMap ¶
func IterateInterfaceAsMap(a interface{}, onIterate func(k, v interface{}))
func IterateInterfaceAsSlice ¶
func IterateInterfaceAsSlice(a interface{}, onIterate func(iterItem interface{}) (keepIterate bool))
IterateInterfaceAsSlice
遍历切片`a`,通过`onIterate`逐个回调元素
@param onIterate:
@return keepIterate: 如果返回false,则停止变化
func Map2Strings ¶
func Slice2Strings ¶
Slice2Strings 将任意类型切片转换为字符串切片
@param a: 任意类型切片,比如结构体切片 @param fn: 业务方编写转换逻辑,内部对原始切片的元素逐个回调给业务方,并通过回调返回值组成转换后的字符串切片
@return ret: 转换后的字符串切片
func Slice2Times ¶
Slice2Times 将任意类型切片转换为时间切片
func SliceAllOf ¶ added in v0.28.0
func SliceLimit ¶
SliceLimit 取切片前`PrefixNumLimit`个元素和后`SuffixNumLimit`个元素,通过`cb`回调给业务方
注意,内部会处理`PrefixNumLimit`或`SuffixNumLimit`过大的情况 `PrefixNumLimit`如果为-1,则没有限制,`SuffixNumLimit`同理
func SliceMinMax ¶ added in v0.28.0
func SliceUniqueCount ¶
SliceUniqueCount 遍历切片`a`,逐个调用`fn`转换为string, 并将所有元素归类计数
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.