dataops

package
v0.25.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

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{}))

IterateInterfaceAsSlice

遍历切片`a`,通过`onIterate`逐个回调元素

func Map2Strings

func Map2Strings(a interface{}, fn func(k, v interface{}) string) (ret []string)

func Slice2Strings

func Slice2Strings(a interface{}, fn func(originItem interface{}) string) (ret []string)

Slice2Strings 将任意类型切片转换为字符串切片

@param a: 任意类型切片,比如结构体切片 @param fn: 业务方编写转换逻辑,内部对原始切片的元素逐个回调给业务方,并通过回调返回值组成转换后的字符串切片

@return ret: 转换后的字符串切片

func Slice2Times

func Slice2Times(a interface{}, fn func(originItem interface{}) time.Time) (ret []time.Time)

Slice2Times 将任意类型切片转换为时间切片

func SliceLimit

func SliceLimit(a interface{}, PrefixNumLimit int, SuffixNumLimit int, cb func(index int))

SliceLimit 取切片前`PrefixNumLimit`个元素和后`SuffixNumLimit`个元素,通过`cb`回调给业务方

注意,内部会处理`PrefixNumLimit`或`SuffixNumLimit`过大的情况
`PrefixNumLimit`如果为-1,则没有限制,`SuffixNumLimit`同理

func SliceUniqueCount

func SliceUniqueCount(a interface{}, fn func(originItem interface{}) string) (ret map[string]int)

SliceUniqueCount 遍历切片`a`,逐个调用`fn`转换为string, 并将所有元素归类计数

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL