# README
Helper
1.仓库迁移至☞ https://github.com/golangtoolkit/helper
2.一些常用的助手函数工具包
包含:
字符串 (TStr)
数组 (TArr)
整型 (TInt)
浮点型 (TFloat)
文件 (TFile)
url (TUri)
hash (THash)
动态调用方法 (TCallFunc)
debug (TDebug)
os (TOs)
类型转换 (TConv)
时间 (TTime)
定时任务 (TCorn)
uuid (TUuid)
json (TJson)
加解密 (TEncrypt)
以上操作☝☝☝
3.获取 ❤❤❤
go version >= 1.15
go get github.com/golangtoolkit/helper
4. 示例 for example
package helper
import (
"fmt"
"github.com/golangtoolkit/helper"
)
func example() {
// string
s1 := `123456`
md5 := helper.TStr.MD5(s1)
fmt.Println(md5) // E10ADC3949BA59ABBE56E057F20F883E
s2 := `hello world`
ucFirst := helper.TStr.UcFirst(s2)
fmt.Println(ucFirst) // Hello world
sfx := helper.TStr.Shuffle(s1)
fmt.Println(sfx) // 125436
// array
arr := [5]int{1, 2, 3, 4, 5}
i := 2
if helper.TArr.InArray(i, arr) {
fmt.Printf(" %v in %v \n", i, arr) // 2 in [1 2 3 4 5]
}
// debug
funcName := helper.TDebug.GetFuncName(helper.TArr.ArrayDiff, true) // ...ArrayDiff-fm
fmt.Println(funcName) // ArrayDiff-fm
// float
round := helper.TFloat.Round(4.56)
fmt.Println(round) // 4
// json
jsonArr := `[{"email_address":"[email protected]"},{"email_address":"[email protected]"}]`
m := helper.TJson.JsonToMapArr(jsonArr)
fmt.Println(m) // [map[email_address:[email protected]] map[email_address:[email protected]]]
// convert
inter := helper.TConv.Int2Str(s1)
fmt.Println(inter) // 123456
// hash
h := "abc123tre"
hashcode := helper.THash.HashCode(h)
fmt.Println(hashcode) // 44
// os
endian := helper.TOs.GetEndian()
fmt.Println(endian) // LittleEndian
// file
f := "./testname.txt"
fileName := helper.TFile.Basename(f)
fmt.Println(fileName) // testname.txt
// encrypt
ek := "Key"
enc := helper.TEncrypt.EasyEncrypt(s1, ek)
fmt.Println(enc) // 89735695aWtqZ2ps
dec := helper.TEncrypt.EasyDecrypt(enc, ek)
fmt.Println(dec) // 123456
// url
uri := `http://localhost/report?Av=5.3.5&Bd=bdtest&Cid=023&CityCode=101030100&Did=70836bc3ae68fddbc78ce5a917ae9e9d60c712df&Imei=`
qm := helper.TUri.ParseUriQueryToMap(uri)
fmt.Println(qm) // map[Av:5.3.5 Bd:bdtest Cid:023 CityCode:101030100 Did:70836bc3ae68fddbc78ce5a917ae9e9d60c712df Imei:]
// int
abs := helper.TInt.Abs(-1)
fmt.Println(abs) // 1
// time
days := helper.TTime.GetMonthDays(2)
fmt.Println(days) // 28
// validate
isEven := helper.TInt.IsEven(3)
fmt.Println(isEven) // false
// ... other
}
5. 使用过程如有疑问欢迎issue 。◕‿◕。
# Constants
CaseLower 检查小写.
CaseNone 忽略大小写.
CaseUpper 检查大写.
CheckConnectTimeout 检查连接超时的时间.
DynamicKeyLen AuthCode 动态密钥长度,须<32.
FloatDecimal 默认浮点数精确小数位数.
GJsonFalse is a json false boolean.
GJsonJSON is a raw block of JSON.
GJsonNull is a null json value.
GJsonNumber is json number.
GJsonString is a json string.
GJsonTrue is a json true boolean.
No description provided by the author
PatternAlphaLower 正则模式-小写英文.
PatternAlphaNumeric 正则模式-字母和数字.
PatternAlphaUpper 正则模式-大写英文.
PatternBase64 正则模式-base64字符串.
PatternBase64Image 正则模式-base64编码图片.
PatternChineseAll 正则模式-全中文.
PatternChineseName 正则模式-中文名称.
PatternCreditNo 正则模式-身份证号码,18位或15位.
PatternDatetime 正则模式-日期时间.
PatternDNSName 正则模式DNS名称.
PatternEmail 正则模式-邮箱.
PatternFloat 正则模式-浮点数.
PatternFullwidth 正则模式-全角字符.
PatternHalfWidth 正则模式-半角字符.
PatternMd5 正则模式-MD5.
PatternMobileCN 正则模式-大陆手机号.
PatternMultibyte 正则模式-多字节字符.
PatternPhone 正则模式-电话(手机或固话).
PatternRGBColor 正则模式-RGB颜色.
PatternSha1 正则模式-SHA1.
PatternSha256 正则模式-SHA256.
PatternSha512 正则模式-SHA512.
PatternTel4800 正则模式-400或800.
PatternTelephone 正则模式-座机号(固定电话或400或800).
PatternTelFix 正则模式-固定电话.
PatternWhitespaceAll 正则模式-全空白字符.
PatternWhitespaceHas 正则模式-带空白字符.
RandStringAlpha 随机字符串类型,字母.
RandStringAluminum 随机字符串类型,字母+数值.
RandStringChinese 随机字符串类型,仅中文.
RandStringNumeric 随机字符串类型,数值.
RandStringSpecial 随机字符串类型,字母+数值+特殊字符.
No description provided by the author
# Variables
CreditArea 身份证区域.
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
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
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
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
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
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
transfer.
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
No description provided by the author
GJsonResult represents a json value that is returned from Get().
No description provided by the author
SystemInfo 系统信息.
# Type aliases
No description provided by the author
ControllerMapsType 方法集合.
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
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
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