package
1.2.4
Repository: https://github.com/helays/utils.git
Documentation: pkg.go.dev

# Functions

Any2bool 尝试将任意类型转换为 bool.
Any2Byte 将任意类型转换为字节数组.
Any2bytes 尝试将任意类型转换为 []byte.
Any2float64 尝试将任意类型转换为 float64.
Any2int 尝试将任意类型转换为 int.
Any2Reader 将任意类型转换为 io.Reader.
No description provided by the author
AnySlice2Str 将任意切片转成字符串.
AutoDetectTimestampString 解析字符串形式的时间戳并转换为 time.Time 对象 timestampStr 是时间戳字符串 这个函数在最近一百年内还是挺好使的哈,过了2286-11-21 01:46:39 就不管用了.
AutoTimeDuration 自动转换时间单位,主要是用于 ini json yaml 几种配置文件 解析出来的时间单位不一致。.
No description provided by the author
AvgInt32 计算平均数.
No description provided by the author
No description provided by the author
No description provided by the author
Booltostring 布尔转 1 0.
ByteFormat 字节格式化.
BytesToInt 字节转换成整形.
No description provided by the author
CamelString 蛇形转驼峰.
CreateSignature 带有 密钥的 sha1 hash.
CutStrSlice2Slice 获取切片的子切片.
DeleteStrarr 删除字符串切片的某一个元素.
EmptyString2 空字符串转为 -.
Fileabs 生成文件的绝对路径.
FileAppendContents 快速简易写文件(追加).
FileGetContents 快速简易读取文件.
FilePutContents 快速简易写文件.
No description provided by the author
No description provided by the author
No description provided by the author
GetIpVersion 解析ip地址,确认ip版本.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Map2Struct 将map转换为结构体 dst 需要传入一个变量的指针.
MapDeepCopy map 深拷贝.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
MinMaxAvgSum 获取数组中最大值最小值平均值和求和.
No description provided by the author
Mkdir 判断目录是否存在,否则创建目录.
No description provided by the author
No description provided by the author
No description provided by the author
PadRight 在字符串后面补齐固定字符,并达到n个长度.
ProbabilityTrigger 使用线程安全的随机数生成器根据给定的概率触发事件.
RandomString 伪随机字符串.
ReverseMapUnique 反转值唯一的 map.
RunAsyncFunc 异步运行.
RunAsyncTickerFunc 异步运行,并定时执行 ctx 用于控制循环的退出 enable 是否启用 d 执行间隔 f 要执行的函数 runFirst 是否先执行一次.
RunAsyncTickerProbabilityFunc 异步运行,并定时执行,概率触发.
RunSyncFunc 同步运行.
No description provided by the author
SearchIntSlice 在整数切片中搜索指定的元素,并返回是否找到。 参数: s - 待搜索的整数。 arr - 整数切片,将被搜索。 返回值: 如果找到 s 在 arr 中,则返回 true;否则返回 false。.
Searchslice 在切片中判断某个值是否存在.
No description provided by the author
Slice2MapWithHeader 主要是将excel 或者 csv的每一行转为map,键为header,值为cell.
SnakeString 将驼峰命名法的字符串转换为蛇形命名法(小写字母加下划线).
Str2StrSlice 字符串转切片.
StringUniq 对字符串切片进行去重.
StrToFloat64 字符串转 float 64.
Struct2Map 将结构体转换为map.
Ternary 是一个通用的三元运算函数。 它接受一个布尔条件和两个参数 a 和 b。 如果条件为 true,则返回 a;否则返回 b。.
No description provided by the author
No description provided by the author
No description provided by the author
UrlEncode 将 query部分进行 url encode.