Categorygithub.com/reber0/goutils
modulepackage
0.3.1
Repository: https://github.com/reber0/goutils.git
Documentation: pkg.go.dev

# README

goutils

go 常用函数

# Functions

AesDecrypt AES 解密,CBC,key 的长度必须为 16, 24 或者 32.
AesEncrypt AES 加密,CBC,key 的长度必须为 16, 24 或者 32.
Base64Decode base64 解码.
Base64Encode base64 编码.
No description provided by the author
EncodeToUTF8 根据 resty 的 resp 获取 utf-8 编码的 html.
FileEachLineRead 按行读取文件内容.
FileGetContents 获取文件内容.
GetRatio 获取两个 string 的相似度 https://github.com/syyongx/php2go/blob/master/php.go#L870.
GetTermWidth 获取终端宽度.
Go 格式转为 JsonStr.
No description provided by the author
HexDecode str 转 16 进制字符串.
HTMLEntityDecode html 实体解码.
HTMLEntityEncode html 实体编码.
IsInCol 判断 elem 是否在 collection(slice, array, map) 中 https://github.com/syyongx/php2go/blob/master/php.go#L1265.
IsPortOpenSyn 判断端口是否 open.
IsSiteLive 判断网站是否存活.
IsValidIP 判断是否为合法 IP.
jsonStr 转为 gjson.Result.
Md5 加密.
NewLog 初始化 MyLog log := pkg.NewLog().L() log.Info("info") log.Error("error").
NewURL 解析 URL.
Num2Float64 : accept numeric types, return float64-value.
ParseIP 解析 ip 为列表(排除了 0 和 255) target := "1.1.1.1,2.2.2.2-5,3.3.3.3/30" ips := ParseIP(target) // ips: [1.1.1.1 // 2.2.2.2 2.2.2.3 2.2.2.4 2.2.2.5 // 3.3.3.1 3.3.3.2 3.3.3.3].
PathExists 判定 文件/文件夹 是否存在.
PKCS7Padding AES padding.
PKCS7UnPadding AES unpadding.
RandomInt 获取区间中的一个随机整数,返回数字范围 [min, max].
RandomString 获取指定长度的随机字符串(数字+大小写字母) temStr := RandomString(12) fmt.Println(temStr) // 8Tb7VQqZ5gL4.
RandomUserAgent 随机生成 X-Forwarded-For.
RandomXFF 随机生成 X-Forwarded-For.
No description provided by the author
Sha1 加密.
Sha256 加密.
Sha512 加密.
SliceListReverse 反转 [][]string.
SortSlice 对 []int、[]string 排序.
HexEncode 16 进制字符串转 str.
Str2Unicode str 转 unicode.
Str2Unix 将时间字符串转化为东八区时间戳 timeStr := "2022-06-20 19:52:04" tt := Str2Unix(timeStr) fmt.Println(tt) // 1655725924.
Unicode2Str unicode 转 str.
UniqSlice 对 []int、[]string 去重.
UniqSlice2D 对 [][]int、[][]string 去重.
Unix2Str 时间戳转时间字符串 var t1 int = 1655725924 var t2 int64 = 1655725924 var t3 string = "1655725924" timeStr1, _ := Unix2String(t1) timeStr2, _ := Unix2String(t2) timeStr3, _ := Unix2String(t3) fmt.Println(timeStr1) // "2022-06-20 19:52:04" fmt.Println(timeStr2) // "2022-06-20 19:52:04" fmt.Println(timeStr3) // "2022-06-20 19:52:04".
URLDecode URL 解码.
URLEncode URL 编码.
No description provided by the author

# Structs

MyLog 自定义 log.
URL 解析 url.