Documentation
¶
Index ¶
- Constants
- func AesDecode(encryptedString, key string) (string, error)deprecated
- func AesEncode(rawString, key string) (string, error)deprecated
- func Base64Decode(encodedString string) ([]byte, error)deprecated
- func Base64Encode(rawBytes []byte) stringdeprecated
- func BytesToStr(b []byte) string
- func CharCodeAt(character string) runedeprecated
- func Crc32Checksum(data []byte, table *crc32.Table) uint32deprecated
- func Crc32ChecksumIEEE(data []byte) uint32deprecated
- func Crc64Checksum(data []byte, table *crc64.Table) uint64deprecated
- func Crc64ChecksumECMA(data []byte) uint64deprecated
- func FileAppendContents(content []byte, dst string) errordeprecated
- func FileExists(dst string) booldeprecated
- func FileExistsWithError(dst string) (bool, error)deprecated
- func FileExt(filename string) stringdeprecated
- func FileGetContents(filename string) ([]byte, error)deprecated
- func FileGetContentsReadLine(dst string) (<-chan string, error)deprecated
- func FilePutContents(content []byte, dst string) errordeprecated
- func FormatDate(date time.Time, dateStyle DateStyle) stringdeprecated
- func FromCharCode(code int32) stringdeprecated
- func GenerateVAPIDKeys() (privateKey string, publicKey string, err error)deprecated
- func GetLocalIP() (string, error)deprecated
- func GzipCompress(content []byte) []bytedeprecated
- func GzipDecompress(content []byte) []bytedeprecated
- func ListeningExitSignal(wg *sync.WaitGroup)deprecated
- func LookupCNAME(domain, cnameTarget string) booldeprecated
- func MD5Encode(rawString string) stringdeprecated
- func ParseDate(date, layout string, loc *time.Location) (time.Time, error)deprecated
- func Pow(x, y int64) int64deprecated
- func PrintSwaggerControllerInfo(param SwaggerControllerInfoParamDeprecated) stringdeprecated
- func PrintSwaggerSummaryInfo(param SwaggerSummaryInfoParamDeprecated) stringdeprecated
- func PrintVersion(fields VersionInfoFieldsDeprecated)deprecated
- func RSADecrypt(encodedString string, privateKey []byte) (string, error)deprecated
- func RSAEncrypt(rawString string, publicKey []byte) (string, error)deprecated
- func RSASign(rawStringBytes, privateKey []byte) (string, error)deprecated
- func RSAVerifySign(rawStringBytes, sign, publicKey []byte) (bool, error)deprecated
- func RandomComplexString(length int) stringdeprecated
- func RandomDigitalChars(length int) stringdeprecated
- func RandomFloat64(start, end float64, precision int) float64deprecated
- func RandomInt64(start, end int64) int64deprecated
- func RandomLetters(length int) stringdeprecated
- func RandomString(length int) string
- func RedisClusterLock(key string) bool
- func RedisClusterLockWithContext(ctx context.Context, key string) bool
- func RedisClusterUnlock(key string)
- func RedisClusterUnlockWithContext(ctx context.Context, key string)
- func RedisLock(ctx context.Context, key string)deprecated
- func RedisStandaloneLock(key string) bool
- func RedisStandaloneLockWithContext(ctx context.Context, key string) bool
- func RedisStandaloneUnlock(key string)
- func RedisStandaloneUnlockWithContext(ctx context.Context, key string)
- func RedisTryLock(key string) booldeprecated
- func RedisTryLockWithContext(ctx context.Context, key string) booldeprecated
- func RedisUnlock(key string)deprecated
- func RedisUnlockWithContext(ctx context.Context, key string)deprecated
- func RefererMatchDomain(referer, domain string) booldeprecated
- func ReportCertAndKeyWhetherMatch(certData, keyData []byte) (bool, error)deprecated
- func ReportCertValidity(domain string, pemData []byte) (bool, time.Time, time.Time, error)deprecated
- func SM4ECBDecrypt(hexKey, base64Raw string) (string, error)deprecated
- func SM4ECBEncrypt(hexKey, raw string) (string, error)deprecated
- func SaveFile2Dst(file *multipart.FileHeader, dst string) errordeprecated
- func SendNotification(privateKey, publicKey string, sub webpush.Subscription, subscriberEmail string, ...) errordeprecated
- func SendRequest(method, url string, jsonPayload []byte, headers map[string]string, ...) (response []byte, statusCode int, err error)deprecated
- func StrToBytes(s string) []byte
- func StringPaddingBoth(rawString, padChar string, length int) stringdeprecated
- func StringPaddingLeft(rawString, padChar string, length int) stringdeprecated
- func StringPaddingRight(rawString, padChar string, length int) stringdeprecated
- func StringReverse(s string) stringdeprecated
- func StringShuffle(s string) stringdeprecated
- func ValidateDomain(domain string) booldeprecated
- func ValidateDomainWithWildcard(domain string) booldeprecated
- func ValidateEmail(email string) booldeprecated
- func ValidateIdentityCard(idCard string) booldeprecated
- func Wordwrap(rawStr string, length int, split string) stringdeprecated
- func WrapRedisKey(appName, key string) stringdeprecated
- type CancelFunc
- type DateStyle
- type HeapHelper
- type HeapStd
- type IAes
- type IAnyValue
- type IBase64
- type ICert
- type ICrc32
- type ICrc64
- type IDatetime
- type IDomain
- type IFile
- type IGzip
- type IHttpClient
- type IIP
- type IMD5
- type INumber
- type IRedisLocker
- type IRsa
- type ISM4
- type ISignal
- type IString
- type ISwagger
- type IValidator
- type IVersion
- type IWebPush
- type Payload
- type PayloadDataField
- type PayloadDataFieldDeprecated
- type PayloadDeprecated
- type SwaggerControllerInfoParam
- type SwaggerControllerInfoParamDeprecated
- type SwaggerSummaryInfoParam
- type SwaggerSummaryInfoParamDeprecated
- type TIM
- type VersionInfoFields
- type VersionInfoFieldsDeprecated
Constants ¶
const ( MM_DD = "MM-dd" YYYYMM = "yyyyMM" YYYY_MM = "yyyy-MM" YYYY_MM_DD = "yyyy-MM-dd" YYYYMMDD = "yyyyMMdd" YYYYMMDDHHMMSS = "yyyyMMddHHmmss" YYYYMMDDHHMM = "yyyyMMddHHmm" YYYYMMDDHH = "yyyyMMddHH" YYMMDDHHMM = "yyMMddHHmm" MM_DD_HH_MM = "MM-dd HH:mm" MM_DD_HH_MM_SS = "MM-dd HH:mm:ss" YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm" YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss" YYYY_MM_DD_HH_MM_SS_SSS = "yyyy-MM-dd HH:mm:ss.SSS" MM_DD_EN = "MM/dd" YYYY_MM_EN = "yyyy/MM" YYYY_MM_DD_EN = "yyyy/MM/dd" MM_DD_HH_MM_EN = "MM/dd HH:mm" MM_DD_HH_MM_SS_EN = "MM/dd HH:mm:ss" YYYY_MM_DD_HH_MM_EN = "yyyy/MM/dd HH:mm" YYYY_MM_DD_HH_MM_SS_EN = "yyyy/MM/dd HH:mm:ss" YYYY_MM_DD_HH_MM_SS_SSS_EN = "yyyy/MM/dd HH:mm:ss.SSS" MM_DD_CN = "MM月dd日" YYYY_MM_CN = "yyyy年MM月" YYYY_MM_DD_CN = "yyyy年MM月dd日" MM_DD_HH_MM_CN = "MM月dd日 HH:mm" MM_DD_HH_MM_SS_CN = "MM月dd日 HH:mm:ss" YYYY_MM_DD_HH_MM_CN = "yyyy年MM月dd日 HH:mm" YYYY_MM_DD_HH_MM_SS_CN = "yyyy年MM月dd日 HH:mm:ss" HH_MM = "HH:mm" HH_MM_SS = "HH:mm:ss" HH_MM_SS_MS = "HH:mm:ss.SSS" )
Variables ¶
This section is empty.
Functions ¶
func Base64Decode
deprecated
func Base64Encode
deprecated
func CharCodeAt
deprecated
added in
v3.0.4
func Crc32Checksum
deprecated
added in
v3.0.2
func Crc32ChecksumIEEE
deprecated
added in
v3.0.2
func Crc64Checksum
deprecated
added in
v3.0.2
func Crc64ChecksumECMA
deprecated
added in
v3.0.2
func FileAppendContents
deprecated
func FileExists
deprecated
func FileExistsWithError
deprecated
func FileGetContents
deprecated
func FileGetContentsReadLine
deprecated
func FilePutContents
deprecated
func FormatDate
deprecated
added in
v3.0.1
func FromCharCode
deprecated
added in
v3.0.4
FromCharCode 返回ASCII码对应的字符
Deprecated: FromCharCode is deprecated,it will be removed in the future.
Please use String().FromCharCode() instead.
Note ¶
常规ASCII码表范围为0~127
扩展ASCII码表范围为128~255
func GenerateVAPIDKeys
deprecated
func GetLocalIP
deprecated
func GzipCompress
deprecated
added in
v3.0.5
func GzipDecompress
deprecated
added in
v3.0.5
func ListeningExitSignal
deprecated
func LookupCNAME
deprecated
added in
v3.0.5
func PrintSwaggerControllerInfo
deprecated
func PrintSwaggerControllerInfo(param SwaggerControllerInfoParamDeprecated) string
PrintSwaggerControllerInfo 打印swagger控制器信息
Deprecated: PrintSwaggerControllerInfo is deprecated,it will be removed in the future.
Please use Swagger().PrintControllerInfo() instead.
用于生成swagger注释
func PrintSwaggerSummaryInfo
deprecated
func PrintSwaggerSummaryInfo(param SwaggerSummaryInfoParamDeprecated) string
PrintSwaggerSummaryInfo 打印swagger概览信息参数
Deprecated: PrintSwaggerSummaryInfo is deprecated,it will be removed in the future.
Please use Swagger().PrintSummaryInfo() instead.
用于生成swagger注释
func PrintVersion
deprecated
added in
v3.0.1
func PrintVersion(fields VersionInfoFieldsDeprecated)
PrintVersion 打印版本信息
Deprecated: PrintVersion is deprecated,it will be removed in the future.
Please use Version().Print() instead.
func RSADecrypt
deprecated
func RSAEncrypt
deprecated
func RSAVerifySign
deprecated
func RandomComplexString
deprecated
added in
v3.0.2
func RandomDigitalChars
deprecated
func RandomFloat64
deprecated
added in
v3.0.5
RandomFloat64 在指定范围内取随机浮点数
Deprecated: RandomFloat64 is deprecated,it will be removed in the future.
Please use Number().RandomFloat64() instead.
start和end同时支持正负数
precision为精度,此参数将限定返回值的最大小数位数
结果值区间 ∈ [start, end)
Note ¶
若start大于end将panic
Example: ¶
result := RandomFloat64(10.10, 20.20, 2) //-> 16.22
result := RandomFloat64(-10.10, 20.20, 3) //-> -7.222
result := RandomFloat64(-20.20, -10.10101010101, 4) //-> -8.1234
func RandomInt64
deprecated
added in
v3.0.5
RandomInt64 在指定范围内取随机整数
Deprecated: RandomInt64 is deprecated,it will be removed in the future.
Please use Number().RandomInt64() instead.
start和end同时支持正负数
结果值区间 ∈ [start, end)
Note ¶
若start大于end将panic
Example: ¶
result := RandomInt64(10, 20) //-> 13
result := RandomInt64(-10, 20) //-> 3
result := RandomInt64(-20, -10) //-> -7
func RandomLetters
deprecated
func RedisClusterLockWithContext ¶ added in v3.0.4
RedisClusterLockWithContext redis锁-上锁(使用cluster)
using SetNX
func RedisClusterUnlock ¶
func RedisClusterUnlock(key string)
RedisClusterUnlock redis锁-解锁(使用cluster)
using SetNX
func RedisClusterUnlockWithContext ¶ added in v3.0.4
RedisClusterUnlockWithContext redis锁-解锁(使用cluster)
using SetNX
func RedisStandaloneLockWithContext ¶ added in v3.0.4
RedisStandaloneLockWithContext redis锁-上锁(使用standalone)
using SetNX
func RedisStandaloneUnlock ¶ added in v3.0.1
func RedisStandaloneUnlock(key string)
RedisStandaloneUnlock redis锁-解锁(使用standalone)
using SetNX
func RedisStandaloneUnlockWithContext ¶ added in v3.0.4
RedisStandaloneUnlockWithContext redis锁-解锁(使用standalone)
using SetNX
func RedisTryLock
deprecated
added in
v3.0.2
func RedisTryLockWithContext
deprecated
added in
v3.0.4
RedisTryLockWithContext redis锁-尝试上锁(自动推测连接类型)
Deprecated: RedisTryLockWithContext is deprecated,it will be removed in the future.
Please use RedisLocker().TryLockWithContext() instead.
using SetNX
与之对应的是使用 RedisUnlock 解锁
Note ¶
该方法会立即返回锁定成功与否的结果
func RedisUnlock
deprecated
func RedisUnlock(key string)
RedisUnlock redis锁-解锁(自动推测连接类型)
Deprecated: RedisUnlock is deprecated,it will be removed in the future.
Please use RedisLocker().Unlock() instead.
using SetNX
func RedisUnlockWithContext
deprecated
added in
v3.0.4
func RefererMatchDomain
deprecated
added in
v3.0.5
func ReportCertAndKeyWhetherMatch
deprecated
added in
v3.0.5
func ReportCertValidity
deprecated
added in
v3.0.5
ReportCertValidity 报告证书有效性
Deprecated: ReportCertValidity is deprecated,it will be removed in the future.
Please use Cert().ReportValidity() instead.
参数:
- domain: 域名
- pemData: 包含 -----BEGIN CERTIFICATE----- xx -----END CERTIFICATE----- 的证书链,格式为pem或crt
返回值:
- 是否有效
- 证书有效期开始时间
- 证书有效期结束时间
- 错误
func SM4ECBDecrypt
deprecated
added in
v3.0.1
func SM4ECBEncrypt
deprecated
added in
v3.0.1
func SaveFile2Dst
deprecated
func SaveFile2Dst(file *multipart.FileHeader, dst string) error
SaveFile2Dst 将文件保存到目标地址(拷贝文件)
Deprecated: SaveFile2Dst is deprecated,it will be removed in the future.
Please use File().Save2Dst() instead.
file *multipart.FileHeader 文件
dst string 拷贝到的目标地址
func SendNotification
deprecated
func SendNotification(privateKey, publicKey string, sub webpush.Subscription, subscriberEmail string, body PayloadDeprecated) error
SendNotification 发送通知
Deprecated: SendNotification is deprecated,it will be removed in the future.
Please use WebPush().SendNotification() instead.
func SendRequest
deprecated
added in
v3.0.5
func SendRequest(method, url string, jsonPayload []byte, headers map[string]string, timeout ...time.Duration) (response []byte, statusCode int, err error)
SendRequest 发送请求
Deprecated: SendRequest is deprecated,it will be removed in the future.
Please use HttpClient().SendRequest() instead.
默认Content-Type为application/json; charset=utf-8
func StringPaddingBoth
deprecated
added in
v3.0.2
StringPaddingBoth 向两端填充字符串
Deprecated: StringPaddingBoth is deprecated,it will be removed in the future.
Please use String().PaddingBoth() instead.
rawString 原字符
padChar 填充字符
length 最终字符长度
Note ¶
如果填充长度不能均分,那么右侧多填充一个字符,如:
rawString = "a",padChar = "#",length = 4
则:
result = "#a##"
func StringPaddingLeft
deprecated
added in
v3.0.2
func StringPaddingRight
deprecated
added in
v3.0.2
func StringReverse
deprecated
added in
v3.0.2
func StringShuffle
deprecated
added in
v3.0.2
func ValidateDomain
deprecated
added in
v3.0.5
func ValidateDomainWithWildcard
deprecated
added in
v3.0.5
ValidateDomainWithWildcard 验证域名是否合法
Deprecated: ValidateDomainWithWildcard is deprecated,it will be removed in the future.
Please use Domain().ValidateWithWildcard() instead.
包含通配符规则验证
eg.
example.com -> ✔
x.example.com -> ✔
*.example.com -> ✔
*example.com -> ✖
example*.com -> ✖
func ValidateEmail
deprecated
func ValidateIdentityCard
deprecated
added in
v3.0.1
ValidateIdentityCard (中国大陆)身份证格式校验
Deprecated: ValidateIdentityCard is deprecated,it will be removed in the future.
Please use Validator().IdentityCard() instead.
计算规则参考“中国国家标准化管理委员会”
官方文档@see http://www.gb688.cn/bzgk/gb/newGbInfo?hcno=080D6FBF2BB468F9007657F26D60013E
func WrapRedisKey
deprecated
Types ¶
type CancelFunc ¶ added in v3.0.2
type CancelFunc func()
type HeapHelper ¶ added in v3.0.4
type HeapHelper interface {
// Push 将数据添加到堆中
Push(value IAnyValue)
// Pop 将数据从堆中取出
Pop() IAnyValue
}
func NewHeap ¶ added in v3.0.4
func NewHeap() HeapHelper
NewHeap 初始化一个全新的堆
它的作用是可以对任意数据类型的切片进行排序
实现 IAnyValue.SortByAsc 方法可以指定排序规则(升序、降序)
IAnyValue.GetScore 方法是排序的数值依据
type IAes ¶ added in v3.0.5
type IAes interface {
// Encode aes加密
//
// 使用CFB
//
// key应该是一个16或24或32位长度的字符
Encode(rawString, key string) (string, error)
// Decode aes解密
//
// 使用CFB
//
// key应该是一个16或24或32位长度的字符
Decode(encryptedString, key string) (string, error)
}
IAes aes接口
type IAnyValue ¶ added in v3.0.4
type IAnyValue interface {
// GetScore 获取对比分值
GetScore() float64
// SortByAsc 指定排序规则
//
// true 为升序(小顶堆)
//
// false 为降序(大顶堆)
SortByAsc() bool
}
IAnyValue 任意值接口
type IBase64 ¶ added in v3.0.5
type IBase64 interface {
// Encode base64编码
Encode(rawBytes []byte) string
// Decode base64解码
Decode(encodedString string) ([]byte, error)
}
IBase64 base64接口
type ICert ¶ added in v3.0.5
type ICert interface {
// ReportValidity 报告证书有效性
//
// 参数:
//
// - domain: 域名
//
// - pemData: 包含 -----BEGIN CERTIFICATE----- xx -----END CERTIFICATE----- 的证书链,格式为pem或crt
//
// 返回值:
//
// - 是否有效
//
// - 证书有效期开始时间
//
// - 证书有效期结束时间
//
// - 错误
ReportValidity(domain string, pemData []byte) (bool, time.Time, time.Time, error)
// ReportKeyWhetherMatch 报告证书和私钥是否匹配
ReportKeyWhetherMatch(certData, keyData []byte) (bool, error)
}
type ICrc32 ¶ added in v3.0.5
type ICrc64 ¶ added in v3.0.5
type IDatetime ¶ added in v3.0.5
type IDomain ¶ added in v3.0.5
type IDomain interface {
// Validate 验证域名是否合法
//
// 不支持通配符
Validate(domain string) bool
// ValidateWithWildcard 验证域名是否合法
//
// 包含通配符规则验证
//
// eg.
//
// example.com -> ✔
//
// x.example.com -> ✔
//
// *.example.com -> ✔
//
// *example.com -> ✖
//
// example*.com -> ✖
ValidateWithWildcard(domain string) bool
// RefererMatch refer是否匹配域名
//
// 提示:
//
// 1.referer和域名大小写不敏感
//
// 2.此函数支持通配符域名检测
RefererMatch(referer, domain string) bool
// LookupCNAME 查询域名cname记录
//
// # 注意
//
// nslookup的结果会在域名后增加一个「.」,
// 因此此函数在对比前会检测cnameTarget参数是否以「.」
// 结尾,如果不是,则会在结尾加上「.」,然后再进行对比。
LookupCNAME(domain, cnameTarget string) bool
}
type IFile ¶ added in v3.0.5
type IFile interface {
// Save2Dst 将文件保存到目标地址(拷贝文件)
//
// file *multipart.FileHeader 文件
//
// dst string 拷贝到的目标地址
Save2Dst(file *multipart.FileHeader, dst string) error
// GetContents 获取文件内容
//
// filename string 文件地址
GetContents(filename string) ([]byte, error)
//PutContents 将内容写入文件(覆盖写)
//
// content []byte 写入的内容
//
// dst string 写入的目标地址
PutContents(content []byte, dst string) error
// AppendContents 将内容写入文件(追加写)
//
// content []byte 写入的内容
//
// dst string 写入的目标地址
AppendContents(content []byte, dst string) error
// Exists 检查文件上是否存在
//
// dst string 目标地址
Exists(dst string) bool
// ExistsWithError 检查文件上是否存在(会返回错误信息)
//
// dst string 目标地址
ExistsWithError(dst string) (bool, error)
// Ext 获取文件扩展名
//
// 根据文件名最后一个.分隔来切分获取
Ext(filename string) string
// GetContentsReadLine 逐行读取文件内容
GetContentsReadLine(dst string) (<-chan string, error)
}
type IGzip ¶ added in v3.0.5
type IHttpClient ¶ added in v3.0.5
type INumber ¶ added in v3.0.5
type INumber interface {
// RandomInt64 在指定范围内取随机整数
//
// start和end同时支持正负数
//
// 结果值区间 ∈ [start, end)
//
// # Note
//
// 若start大于end将panic
//
// # Example:
//
// result := RandomInt64(10, 20)
// //-> 13
//
// result := RandomInt64(-10, 20)
// //-> 3
//
// result := RandomInt64(-20, -10)
// //-> -7
RandomInt64(start, end int64) int64
// RandomFloat64 在指定范围内取随机浮点数
//
// start和end同时支持正负数
//
// precision为精度,此参数将限定返回值的最大小数位数
//
// 结果值区间 ∈ [start, end)
//
// # Note
//
// 若start大于end将panic
//
// # Example:
//
// result := RandomFloat64(10.10, 20.20, 2)
// //-> 16.22
//
// result := RandomFloat64(-10.10, 20.20, 3)
// //-> -7.222
//
// result := RandomFloat64(-20.20, -10.10101010101, 4)
// //-> -8.1234
RandomFloat64(start, end float64, precision int) float64
// Pow 计算x的y次幂
//
// # Note
//
// 若y小于0,将panic
Pow(x, y int64) int64
}
type IRedisLocker ¶ added in v3.0.5
type IRedisLocker interface {
// TryLock redis锁-尝试上锁(自动推测连接类型)
//
// using SetNX
//
// 与之对应的是使用 Unlock 解锁
//
// # Note
//
// 该方法会立即返回锁定成功与否的结果
TryLock(key string) bool
// TryLockWithContext redis锁-尝试上锁(自动推测连接类型)
//
// using SetNX
//
// 与之对应的是使用 Unlock 解锁
//
// # Note
//
// 该方法会立即返回锁定成功与否的结果
TryLockWithContext(ctx context.Context, key string) bool
// Lock redis锁-上锁(自动推测连接类型)
//
// using SetNX
//
// 与之对应的是使用 Unlock 解锁
//
// # Note
//
// 该方法会阻塞住线程直到上锁成功 或者 触发ctx.Done()
Lock(ctx context.Context, key string)
// Unlock redis锁-解锁(自动推测连接类型)
//
// using SetNX
Unlock(key string)
// UnlockWithContext redis锁-解锁(自动推测连接类型)
//
// using SetNX
UnlockWithContext(ctx context.Context, key string)
}
type IRsa ¶ added in v3.0.5
type IRsa interface {
// Encrypt rsa加密
Encrypt(rawString string, publicKey []byte) (string, error)
// Decrypt rsa解密
Decrypt(encodedString string, privateKey []byte) (string, error)
// Sign rsa加签
Sign(rawStringBytes, privateKey []byte) (string, error)
// VerifySign rsa验签
VerifySign(rawStringBytes, sign, publicKey []byte) (bool, error)
}
type ISM4 ¶ added in v3.0.5
type IString ¶ added in v3.0.5
type IString interface {
// Wordwrap 以给定的字符和长度来打断字符串
Wordwrap(rawStr string, length int, split string) string
// WrapRedisKey 包装redis键名
//
// 给redis的键加入应用名前缀,如:
//
// appName=game key=user
//
// 最终的redis键名为:game:user
//
// 此方法的主要作用是按应用来划分redis键名
WrapRedisKey(appName, key string) string
// RandomLetters 随机字符串(字母)
RandomLetters(length int) string
// RandomDigitalChars 随机字符串(数字)
RandomDigitalChars(length int) string
// RandomString 随机字符串(字母+数字)
RandomString(length int) string
// RandomComplexString 随机字符串(可带特殊符号)
RandomComplexString(length int) string
// Reverse 翻转字符串
Reverse(s string) string
// Shuffle 打乱字符串
Shuffle(s string) string
// PaddingLeft 向左填充字符串
//
// rawString 原字符
//
// padChar 填充字符
//
// length 最终字符长度
PaddingLeft(rawString, padChar string, length int) string
// PaddingRight 向右填充字符串
//
// rawString 原字符
//
// padChar 填充字符
//
// length 最终字符长度
PaddingRight(rawString, padChar string, length int) string
// PaddingBoth 向两端填充字符串
//
// rawString 原字符
//
// padChar 填充字符
//
// length 最终字符长度
//
// # Note
//
// 如果填充长度不能均分,那么右侧多填充一个字符,如:
//
// rawString = "a",padChar = "#",length = 4
//
// 则:
//
// result = "#a##"
PaddingBoth(rawString, padChar string, length int) string
// FromCharCode 返回ASCII码对应的字符
//
// # Note
//
// 常规ASCII码表范围为0~127
//
// 扩展ASCII码表范围为128~255
//
// more: https://www.rfc-editor.org/rfc/rfc698.txt
FromCharCode(code int32) string
// CharCodeAt 返回字符对应的ASCII码
CharCodeAt(character string) rune
}
type ISwagger ¶ added in v3.0.5
type ISwagger interface {
// PrintSummaryInfo 打印swagger概览信息参数
//
// 用于生成swagger注释
PrintSummaryInfo(param SwaggerSummaryInfoParam) string
// PrintControllerInfo 打印swagger控制器信息
//
// 用于生成swagger注释
PrintControllerInfo(param SwaggerControllerInfoParam) string
}
type IValidator ¶ added in v3.0.5
type IValidator interface {
// Email 验证邮箱格式
Email(email string) bool
// IdentityCard (中国大陆)身份证格式校验
//
// 计算规则参考“中国国家标准化管理委员会”
//
// 官方文档@see http://www.gb688.cn/bzgk/gb/newGbInfo?hcno=080D6FBF2BB468F9007657F26D60013E
IdentityCard(idCard string) bool
}
type IVersion ¶ added in v3.0.5
type IVersion interface {
// Print 打印版本信息
Print(fields VersionInfoFields)
}
type IWebPush ¶ added in v3.0.5
type Payload ¶
type Payload struct {
Title string `json:"title"`
Body string `json:"body"`
Icon string `json:"icon"`
Data PayloadDataField `json:"data"`
Badge string `json:"badge"`
}
Payload 消息推送载荷
type PayloadDataField ¶
type PayloadDataField struct {
URL string `json:"url"`
}
PayloadDataField 消息推送载荷-data字段
type PayloadDataFieldDeprecated ¶ added in v3.0.5
type PayloadDataFieldDeprecated struct {
URL string `json:"url"`
}
PayloadDataFieldDeprecated 消息推送载荷-data字段
type PayloadDeprecated ¶ added in v3.0.5
type PayloadDeprecated struct {
Title string `json:"title"`
Body string `json:"body"`
Icon string `json:"icon"`
Data PayloadDataFieldDeprecated `json:"data"`
Badge string `json:"badge"`
}
PayloadDeprecated 消息推送载荷
type SwaggerControllerInfoParam ¶
type SwaggerControllerInfoParam struct {
FunctionName string //方法名称
FunctionDesc string //方法描述
Tag string //分类标签
Summary string //简要标题
Description string //接口描述
Method string //请求方法
RequestParamString string //请求参数字符
ResponseBodyString string //返回体字符
ApiPath string //接口路径
NeedAuthorize bool //是否需要授权
}
SwaggerControllerInfoParam 控制器信息参数
type SwaggerControllerInfoParamDeprecated ¶ added in v3.0.5
type SwaggerControllerInfoParamDeprecated struct {
FunctionName string //方法名称
FunctionDesc string //方法描述
Tag string //分类标签
Summary string //简要标题
Description string //接口描述
Method string //请求方法
RequestParamString string //请求参数字符
ResponseBodyString string //返回体字符
ApiPath string //接口路径
NeedAuthorize bool //是否需要授权
}
SwaggerControllerInfoParamDeprecated 控制器信息参数
type SwaggerSummaryInfoParam ¶
type SwaggerSummaryInfoParam struct {
Title string //标题
Version string //版本
Description string //描述
TermOfServiceUrl string //服务条款地址
ContactName string //联系人
ContactUrl string //联系网址
ContactEmail string //联系邮箱
LicenseUrl string //证书网址
Host string //接口主机地址
BasePath string //接口公共前缀路径
NeedAuthorize bool //是否需要token授权
}
SwaggerSummaryInfoParam 概览信息参数
type SwaggerSummaryInfoParamDeprecated ¶ added in v3.0.5
type SwaggerSummaryInfoParamDeprecated struct {
Title string //标题
Version string //版本
Description string //描述
TermOfServiceUrl string //服务条款地址
ContactName string //联系人
ContactUrl string //联系网址
ContactEmail string //联系邮箱
LicenseUrl string //证书网址
Host string //接口主机地址
BasePath string //接口公共前缀路径
NeedAuthorize bool //是否需要token授权
}
SwaggerSummaryInfoParamDeprecated 概览信息参数
type TIM ¶
type TIM struct {
// contains filtered or unexported fields
}
func (*TIM) DatetimeTZ ¶ added in v3.0.4
DatetimeTZ 获取格式化后的当前日期时间-tz
Source Files
¶
- aes.go
- aes_deprecated.go
- base64.go
- base64_deprecated.go
- cert.go
- cert_deprecated.go
- crc.go
- crc_deprecated.go
- datetime.go
- datetime_deprecated.go
- domain.go
- domain_deprecated.go
- file.go
- file_deprecated.go
- gzip.go
- gzip_deprecated.go
- heap.go
- httpclient.go
- httpclient_deprecated.go
- ip.go
- ip_deprecated.go
- md5.go
- md5_deprecated.go
- number.go
- number_deprecated.go
- redislock.go
- redislock_deprecated.go
- rsa.go
- rsa_deprecated.go
- signal.go
- signal_deprecated.go
- sm4.go
- sm4_deprecated.go
- string.go
- string_deprecated.go
- string_go1.22.go
- swagger.go
- swagger_deprecated.go
- time.go
- validator.go
- validator_deprecated.go
- version.go
- version_deprecated.go
- webpush.go
- webpush_deprecated.go