代码拉取完成,页面将自动刷新
封装go语言常用助手函数
go get gitee.com/zjlsliupei/ghelp
// json
data := map[string]interface{}{
"name": "ghelp"
}
encodeStr := ghelp.JsonEncode(data)
decodeMap := ghelp.JsonDecode(encodeStr)
// md5 sha1
str := "1111"
encodeMd5 = ghelp.Md5(str)
encodeSha1 = ghelp.Sha1(str)
fmt.Println(encodeMd5, encodeSha1)
// md5:b59c67bf196a4758191e42f76670ceba
// sha1:011c945f30ce2cbafc452f39840f025693339c42
// base64
data := "hello world"
encodeStr := ghelp.Base64Encode(data)
decodeStr := ghelp.Base64Decode(encodeStr)
fmt.Println(encodeStr, decodeStr)
// encode: VsbG8gd29ybGQ=
// decode: hello world
// 计算crc modbus
data := []byte{255,102}
ghelp.Crc16(data)
// 计算累计校验码
data := []byte{255,102}
ghelp.CheckSum(data)
// 计算签名
param := MAP{
"corp_id": "ding3590d5bb2ae3356d",
"corp_name": "杭州嘉策科技",
"corp_logo_url": "",
"industry": "信息技术",
"auth_info": "",
"platform": 1,
"status": 1,
}
var timestamp int64 = 1687662061
key := "ding3590d5bb2ae3356d"
secret := "12345678"
sign := GenerateSign(param, timestamp, key, secret)
// IsFile
success := IsFile(filePath)
// IsDir
success := IsDir(dirPath)
// CopyFile
writeBytes, err := CopyFile(src, dst)
InArray:判断元素是否在数组中
item1 := "a"
items1 := []string{"a","b","c"}
if !InArray(item1, items1) {
t.Error("a in not in [a,b,c]")
}
excel_col.NextColName:获取下一列名称
fmt.Println(NextColName("Z"))
// output: AA
excel_col.PreColName:获取上一列名称
fmt.Println(NextColName("AA"))
// output: Z
excel_col.FirstColName:获取首列名称
fmt.Println(FirstColName())
// output: A
excel_col.LastColName:获取尾列名称
fmt.Println(LastColName())
// output: XFD
### fn 通用方法
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。