Documentation ¶
Index ¶
- Constants
- Variables
- func CalculateCurrentTimeAndZeroTime() time.Duration
- func CompactStr(str ...string) string
- func ContentFilter(text string) bool
- func CurrentDayEnd() string
- func CurrentDayZero() string
- func Decode(bytesBuffer io.Reader) (bodyBuf []byte, err error)
- func EnValidateParam(param interface{}) string
- func Encode(bytesBuffer io.Writer, content string) error
- func FileMd5(filepath string) (string, error)
- func FilterString(key, value, operator string) func(db *gorm.DB) *gorm.DB
- func Get(url string, header map[string]string, params map[string]interface{}) ([]byte, error)
- func InOrNotInFilter(key string, value interface{}, operator string) func(db *gorm.DB) *gorm.DB
- func LoadConfig(cf string)
- func Md5S(str string) string
- func MergeMap(dest, src map[interface{}]interface{}) map[interface{}]interface{}
- func NewClusterEtcd(addr []string) (*clientv3.Client, error)
- func NewEtcd(addr string) (*clientv3.Client, error)
- func NewGorm(dsn string, args ...[]int) (*gorm.DB, error)
- func NewLogger(fileName string, maxSize int, maxAge int, localTime, compress bool) *zap.Logger
- func NewRedis(addr, password string, db int) (*redis.Client, error)
- func NewTicker(ttl time.Duration, sch chan string, fn func(sch chan string) int)
- func NewXrm(dsn string, showSql bool, args ...[]int) (*xorm.Engine, error)
- func PKCS5Adding(ciphertext []byte, blockSize int) []byte
- func PKCS5UnPadding(origData []byte) []byte
- func Paginate(page interface{}, pageSize interface{}, s map[string]interface{}) func(db *gorm.DB) *gorm.DB
- func Post(url string, header map[string]string, param map[string]interface{}) ([]byte, error)
- func PostMultipart(url string, header map[string]string, payload *bytes.Buffer) ([]byte, error)
- func PreviousAfterDate(n int) string
- func PreviousAfterTime(n int) string
- func PreviousDayEndTime() string
- func PreviousDayStartTime() string
- func PrintConfigMap(config map[string]interface{})
- func QiNiuFileUpload(r *http.Request, store string) (string, error)
- func QiNiuResumeUploadFile(r *http.Request, store string) (string, error)
- func QiNiuUploadChunk(r *http.Request, store string) (string, string, error)
- func SendGmail(from string, to []string, content []byte, ...) (err error)
- func SendGmailEmail(from, to, title, content, mailServer, mailServerPort, mailPassword string) (err error)
- func SendMail(from, to, title, content, mailServer, mailServerPort, mailPassword string) (err error)
- func SetWordsFilter()
- func Sha1(str string) string
- func ToString(i interface{}) (string, error)
- func ZhValidateParam(param interface{}) string
- type AesEncrypt
- type Counter
- type Database
- type EtcdS
- type GMap
- type GoRegs
- func (g *GoRegs) MatchChineseCharacter(str string) bool
- func (g *GoRegs) MatchChineseIDCardNumber(id string) bool
- func (g *GoRegs) MatchChinesePhoneNumber(str string) bool
- func (g *GoRegs) MatchContainChineseCharacter(str string) bool
- func (g *GoRegs) MatchDoubleByte(input string) bool
- func (g *GoRegs) MatchEmail(str string) bool
- func (g *GoRegs) MatchEmptyLine(input string) bool
- func (g *GoRegs) MatchEnCharacter(str string) bool
- func (g *GoRegs) MatchGeNNumber(str string, n int) bool
- func (g *GoRegs) MatchIPv4(input string) bool
- func (g *GoRegs) MatchIPv6(input string) bool
- func (g *GoRegs) MatchIntOrFloat(str string) bool
- func (g *GoRegs) MatchIsContainSpecialCharacter(str string) bool
- func (g *GoRegs) MatchLenNNumber(str string, n int) bool
- func (g *GoRegs) MatchLowerEnCharacter(str string) bool
- func (g *GoRegs) MatchMKNoContainSpecialCharacter(str string, m, k int) bool
- func (g *GoRegs) MatchMNIntervalNumber(str string, m, n int) bool
- func (g *GoRegs) MatchMNLeCharacter(str string, m, z int) bool
- func (g *GoRegs) MatchMNNovelsOfRealNumber(str string, m, n int) bool
- func (g *GoRegs) MatchNLeCharacter(str string, n int) bool
- func (g *GoRegs) MatchNNovelsOfRealNumber(str string, n int) bool
- func (g *GoRegs) MatchNanZeroNegNumber(str string) bool
- func (g *GoRegs) MatchNanZeroNumber(str string) bool
- func (g *GoRegs) MatchNumber(str string) bool
- func (g *GoRegs) MatchNumberEnCharacter(str string) bool
- func (g *GoRegs) MatchNumberEnUnderscores(str string) bool
- func (g *GoRegs) MatchPass1(str string, m, n int) bool
- func (g *GoRegs) MatchPass2(str string) bool
- func (g *GoRegs) MatchStartingWithNonZero(str string) bool
- func (g *GoRegs) MatchUpEnCharacter(str string) bool
- type JwtClaims
- type LeakyBucket
- type LevelDB
- func (db *LevelDB) CountAll() (int64, error)
- func (db *LevelDB) CountPrefixSubsetKey(key string) (int64, error)
- func (db *LevelDB) Delete(key string) error
- func (db *LevelDB) DeleteAll() (bool, error)
- func (db *LevelDB) DeletePrefixSubsetKey(key string) (bool, error)
- func (db *LevelDB) Get(key string) ([]byte, error)
- func (db *LevelDB) Has(key string) (bool, error)
- func (db *LevelDB) Put(key string, value interface{}) error
- func (db *LevelDB) SelectAll() iterator.Iterator
- func (db *LevelDB) SelectPrefixSubsetKeyAll(key string) ([]map[string]interface{}, error)
- type MongoDb
- func (m *MongoDb) BatchInsertCollection(c *mongo.Client, db string, collection string, data []interface{}) (res *mongo.InsertManyResult, err error)
- func (m *MongoDb) CountCollection(c *mongo.Client, db string, collection string, filter map[string]interface{}) (int64, int64, error)
- func (m *MongoDb) DeleteOneRecord(c *mongo.Client, db string, collection string, filter map[string]interface{}) (res *mongo.DeleteResult, err error)
- func (m *MongoDb) InsertCollection(c *mongo.Client, db string, collection string, data interface{}) (res *mongo.InsertOneResult, err error)
- func (m *MongoDb) UpdateOneRecord(c *mongo.Client, db string, collection string, id string, data bson.D) (res *mongo.UpdateResult, err error)
- type TokenBucket
- type ToolsSlice
- func (w *ToolsSlice) CompareSliceByte(s1, s2 []byte) bool
- func (w *ToolsSlice) CompareSliceInt(s1, s2 []int) bool
- func (w *ToolsSlice) CompareSliceStr(s1, s2 []string) bool
- func (w *ToolsSlice) DifferentSet(s1, s2 []string) []string
- func (w *ToolsSlice) ExpandStringSlice(s []string, split string) []string
- func (w *ToolsSlice) InSlice(s string, ts []string) bool
- func (w *ToolsSlice) InSliceInterface(s interface{}, ts []interface{}) bool
- func (w *ToolsSlice) Intersect(s1, s2 []string) []string
- func (w *ToolsSlice) Merge(s1, s2 []string) []string
- func (w *ToolsSlice) MergeRepeatedElement(s1, s2 []string) []string
- func (w *ToolsSlice) MergeSlice(s1, s2 []interface{}) (s3 []interface{})
- func (w *ToolsSlice) MoveStr2Slice(str string, buf []byte)
- func (w *ToolsSlice) RandSlice(min, max int) []int
- func (w *ToolsSlice) RemoveRepeatedElement(arr []string) (newArr []string)
- func (w *ToolsSlice) SliceChunk(s []interface{}, size int) (chunkSlice [][]interface{})
- func (w *ToolsSlice) SliceDiff(s1, s2 []interface{}) (s3 []interface{})
- func (w *ToolsSlice) SliceFilter(s []interface{}, a filterType) (ftSlice []interface{})
- func (w *ToolsSlice) SliceHex2SliceUInt16(s []string) (ret []uint16)
- func (w *ToolsSlice) SliceIntersect(s1, s2 []interface{}) (s3 []interface{})
- func (w *ToolsSlice) SlicePad(slice []interface{}, size int, val interface{}) []interface{}
- func (w *ToolsSlice) SliceRand(a []interface{}) (b interface{})
- func (w *ToolsSlice) SliceRange(start, end, step int64) (intSlice []int64)
- func (w *ToolsSlice) SliceReduce(s []interface{}, a reduceType) (s2 []interface{})
- func (w *ToolsSlice) SliceShuffle(slice []interface{}) []interface{}
- func (w *ToolsSlice) SliceStr2SliceInt(s []string) (ret []int)
- func (w *ToolsSlice) SliceSum(s []int64) (sum int64)
- func (w *ToolsSlice) SliceUnique(slice []interface{}) (uniqueSlice []interface{})
Constants ¶
const MsgHeader = "12345678"
Variables ¶
var (
ErrEmptyKey = errors.New("key could not be empty")
)
var Response *result
var ResponsePage *pageList
var (
Wf *wordsfilter.WordsFilter
)
Functions ¶
func CalculateCurrentTimeAndZeroTime ¶
CalculateCurrentTimeAndZeroTime 计算当前时间和零点的时间差
func CompactStr ¶ added in v0.0.4
CompactStr compact more string
func EnValidateParam ¶
func EnValidateParam(param interface{}) string
EnValidateParam validate params english
func FilterString ¶
FilterString 进行快速条件过滤
func InOrNotInFilter ¶
InOrNotInFilter where in 或者 where not in
func MergeMap ¶
func MergeMap(dest, src map[interface{}]interface{}) map[interface{}]interface{}
MergeMap desc: 合并源 map 到目标 map
func NewGorm ¶
NewGorm gorm 初始化mysql连接 eg: root:123456@tcp(127.0.0.1:3306)/demo?charset=utf8mb4&parseTime=True&loc=Local
func PKCS5Adding ¶
func PKCS5UnPadding ¶
func Paginate ¶
func Paginate(page interface{}, pageSize interface{}, s map[string]interface{}) func(db *gorm.DB) *gorm.DB
Paginate page, pageSize 传入参数 s 分页默认配置
func PostMultipart ¶
func PrintConfigMap ¶ added in v0.0.2
func PrintConfigMap(config map[string]interface{})
func QiNiuFileUpload ¶
QiNiuFileUpload 上传文件到七牛云
func QiNiuResumeUploadFile ¶
QiNiuResumeUploadFile 七牛云文件断点续传
func QiNiuUploadChunk ¶
QiNiuUploadChunk 七牛云分片上传
func SendGmail ¶
func SendGmail(from string, to []string, content []byte, mailServer, mailServerPort, mailPassword string) (err error)
SendGmail 发送谷歌邮件 支持同时给多人发送
func SendGmailEmail ¶
func SendGmailEmail(from, to, title, content, mailServer, mailServerPort, mailPassword string) (err error)
SendGmailEmail 发送谷歌邮件 支持 Gmail邮箱 from 发件人邮箱 `xxxx@gmail.com` to 接受人邮箱 title 邮箱标题 content 邮箱内容 mailServer Gmail邮箱服务地址 `smtp.gmail.com` mailServerPort Gmail邮箱端口 `:587` mailPassword Gmail邮箱登陆密码
func SendMail ¶
func SendMail(from, to, title, content, mailServer, mailServerPort, mailPassword string) (err error)
SendMail 发送邮件 支持 163邮箱、QQ邮箱、126邮箱 from 发件人邮箱 `xxxx@163.com`、`xxxx@qq.com`、`xxxx@126.com` to 接受人邮箱 title 邮箱标题 content 邮箱内容 mailServer 163邮箱服务地址 163: `smtp.163.com`、 QQ邮箱: `smtp.qq.com`、 126邮箱: `smtp.126.com` mailServerPort 163邮箱端口 163: `:465` 、 QQ邮箱端口: `:465`、 126邮箱: `:465` mailPassword 163邮箱、QQ邮箱、126邮箱 授权码 `xxxxxxxxxxx`
func ZhValidateParam ¶
func ZhValidateParam(param interface{}) string
ZhValidateParam validate params english
Types ¶
type AesEncrypt ¶
type AesEncrypt struct {
// contains filtered or unexported fields
}
func NewAesEncryptInstance ¶
func NewAesEncryptInstance(key string, secret string) (*AesEncrypt, error)
func (*AesEncrypt) AesBase64Decrypt ¶
func (a *AesEncrypt) AesBase64Decrypt(b string) (string, error)
AesBase64Decrypt aes Base64 解密
func (*AesEncrypt) AesBase64Encrypt ¶
func (a *AesEncrypt) AesBase64Encrypt(in string) (string, error)
AesBase64Encrypt aes Base64 加密
type Database ¶
type Database interface { Put(key string, value interface{}) error Get(key string) ([]byte, error) Has(key string) (bool, error) Delete(key string) error SelectAll() iterator.Iterator SelectPrefixSubsetKeyAll(key string) ([]map[string]interface{}, error) CountPrefixSubsetKey(key string) (int64, error) CountAll() (int64, error) DeletePrefixSubsetKey(key string) (bool, error) }
type GoRegs ¶
type GoRegs struct{}
func (*GoRegs) MatchChineseCharacter ¶
MatchChineseCharacter 纯汉字
func (*GoRegs) MatchChineseIDCardNumber ¶
MatchChineseIDCardNumber 验证大陆身份证号
func (*GoRegs) MatchChinesePhoneNumber ¶
MatchChinesePhoneNumber 大陆手机号
func (*GoRegs) MatchContainChineseCharacter ¶
MatchContainChineseCharacter 大陆手机号
func (*GoRegs) MatchDoubleByte ¶
MatchDoubleByte 匹配双字节字符(包括汉字在内)
func (*GoRegs) MatchEmptyLine ¶
MatchEmptyLine 匹配零个或多个空白字符(包括空格、制表符、换页符等)
func (*GoRegs) MatchEnCharacter ¶
MatchEnCharacter 纯英文字符串,大小写不敏感
func (*GoRegs) MatchGeNNumber ¶
MatchGeNNumber 长度不小于n位的纯数字
func (*GoRegs) MatchIntOrFloat ¶
MatchIntOrFloat 整数或者小数
func (*GoRegs) MatchIsContainSpecialCharacter ¶
MatchIsContainSpecialCharacter 验证是否包含特殊字符串
func (*GoRegs) MatchLenNNumber ¶
MatchLenNNumber 长度为n的纯数字
func (*GoRegs) MatchLowerEnCharacter ¶
MatchLowerEnCharacter 纯小写英文字符串
func (*GoRegs) MatchMKNoContainSpecialCharacter ¶
MatchMKNoContainSpecialCharacter 长度m-k的字符串,包含数字、字母、汉字,不包含特殊字符 一般多用于校验用户名或昵称等
func (*GoRegs) MatchMNIntervalNumber ¶
MatchMNIntervalNumber 长度m~n位的纯数字
func (*GoRegs) MatchMNLeCharacter ¶
MatchMNLeCharacter 长度m-z的字符串,包含特殊字符、数字、字母、汉字, 一般多用于校验用户名或昵称等
func (*GoRegs) MatchMNNovelsOfRealNumber ¶
MatchMNNovelsOfRealNumber m~n位小数的正实数
func (*GoRegs) MatchNLeCharacter ¶
MatchNLeCharacter 长度为n的字符,特殊字符除外
func (*GoRegs) MatchNNovelsOfRealNumber ¶
MatchNNovelsOfRealNumber 有n位小数的正实数
func (*GoRegs) MatchNanZeroNegNumber ¶
MatchNanZeroNegNumber 非零的负整数
func (*GoRegs) MatchNanZeroNumber ¶
MatchNanZeroNumber 非零的正整数
func (*GoRegs) MatchNumberEnCharacter ¶
MatchNumberEnCharacter 数字和26个英文字母组成的字符串,大小写不敏感
func (*GoRegs) MatchNumberEnUnderscores ¶
MatchNumberEnUnderscores 数字和26个英文字母组成的字符串,大小写不敏感
func (*GoRegs) MatchPass1 ¶
MatchPass1 密码1 由数字、26个英文字母或者下划线组成的英文开头的字符串, 长度m~n位
func (*GoRegs) MatchPass2 ¶
MatchPass2 密码2 密码长度至少为8个字符。 包含至少一个小写字母。 包含至少一个大写字母。 包含至少一个数字。 包含至少一个特殊字符(例如 !@#$%^&*() 等
func (*GoRegs) MatchStartingWithNonZero ¶
MatchStartingWithNonZero 非零开头的纯数字
func (*GoRegs) MatchUpEnCharacter ¶
MatchUpEnCharacter 纯大写英文字符串
type JwtClaims ¶
type JwtClaims struct { Expire time.Duration Secret string LoginInfo interface{} `json:"login_info"` jwt.StandardClaims }
func (*JwtClaims) GenerateToken ¶
GenerateToken 签发Token
type LeakyBucket ¶
type LeakyBucket struct {
// contains filtered or unexported fields
}
func (*LeakyBucket) Pass ¶
func (l *LeakyBucket) Pass() bool
func (*LeakyBucket) Set ¶
func (l *LeakyBucket) Set(r, c float64)
type LevelDB ¶
type LevelDB struct {
// contains filtered or unexported fields
}
func CreateLevelDB ¶
func (*LevelDB) CountPrefixSubsetKey ¶
CountPrefixSubsetKey 计算指定前缀 key 的数量
func (*LevelDB) DeletePrefixSubsetKey ¶
type MongoDb ¶
type MongoDb struct {
// contains filtered or unexported fields
}
func NewMongoDb ¶
NewMongoDb mongodb 连接
func (*MongoDb) BatchInsertCollection ¶
func (m *MongoDb) BatchInsertCollection(c *mongo.Client, db string, collection string, data []interface{}) ( res *mongo.InsertManyResult, err error)
BatchInsertCollection 批量写入
func (*MongoDb) CountCollection ¶
func (m *MongoDb) CountCollection(c *mongo.Client, db string, collection string, filter map[string]interface{}) (int64, int64, error)
CountCollection 统计
func (*MongoDb) DeleteOneRecord ¶
func (m *MongoDb) DeleteOneRecord(c *mongo.Client, db string, collection string, filter map[string]interface{}) ( res *mongo.DeleteResult, err error)
DeleteOneRecord 删除单条记录
func (*MongoDb) InsertCollection ¶
func (m *MongoDb) InsertCollection(c *mongo.Client, db string, collection string, data interface{}) ( res *mongo.InsertOneResult, err error)
InsertCollection 写入 db 写入的数据库 collection 写入的文档(表) data 写入的数据
type TokenBucket ¶
type TokenBucket struct {
// contains filtered or unexported fields
}
func (*TokenBucket) Pass ¶
func (l *TokenBucket) Pass() bool
func (*TokenBucket) Set ¶
func (l *TokenBucket) Set(r, c int64)
type ToolsSlice ¶
type ToolsSlice struct{}
func (*ToolsSlice) CompareSliceByte ¶
func (w *ToolsSlice) CompareSliceByte(s1, s2 []byte) bool
func (*ToolsSlice) CompareSliceInt ¶
func (w *ToolsSlice) CompareSliceInt(s1, s2 []int) bool
func (*ToolsSlice) CompareSliceStr ¶
func (w *ToolsSlice) CompareSliceStr(s1, s2 []string) bool
func (*ToolsSlice) DifferentSet ¶
func (w *ToolsSlice) DifferentSet(s1, s2 []string) []string
DifferentSet 取两个列表的差集
func (*ToolsSlice) ExpandStringSlice ¶
func (w *ToolsSlice) ExpandStringSlice(s []string, split string) []string
func (*ToolsSlice) InSlice ¶
func (w *ToolsSlice) InSlice(s string, ts []string) bool
InSlice 检查字符串是否存在字符串切片中
func (*ToolsSlice) InSliceInterface ¶
func (w *ToolsSlice) InSliceInterface(s interface{}, ts []interface{}) bool
InSliceInterface 检查Interface是否存在Interface切片中
func (*ToolsSlice) Intersect ¶
func (w *ToolsSlice) Intersect(s1, s2 []string) []string
Intersect 取两个列表的交集
func (*ToolsSlice) MergeRepeatedElement ¶
func (w *ToolsSlice) MergeRepeatedElement(s1, s2 []string) []string
MergeRepeatedElement 合集去重
func (*ToolsSlice) MergeSlice ¶
func (w *ToolsSlice) MergeSlice(s1, s2 []interface{}) (s3 []interface{})
MergeSlice merge two interface slices to one slice
func (*ToolsSlice) MoveStr2Slice ¶
func (w *ToolsSlice) MoveStr2Slice(str string, buf []byte)
func (*ToolsSlice) RandSlice ¶
func (w *ToolsSlice) RandSlice(min, max int) []int
func (*ToolsSlice) RemoveRepeatedElement ¶
func (w *ToolsSlice) RemoveRepeatedElement(arr []string) (newArr []string)
RemoveRepeatedElement 数组切片去重
func (*ToolsSlice) SliceChunk ¶
func (w *ToolsSlice) SliceChunk(s []interface{}, size int) (chunkSlice [][]interface{})
func (*ToolsSlice) SliceDiff ¶
func (w *ToolsSlice) SliceDiff(s1, s2 []interface{}) (s3 []interface{})
func (*ToolsSlice) SliceFilter ¶
func (w *ToolsSlice) SliceFilter(s []interface{}, a filterType) (ftSlice []interface{})
func (*ToolsSlice) SliceHex2SliceUInt16 ¶
func (w *ToolsSlice) SliceHex2SliceUInt16(s []string) (ret []uint16)
func (*ToolsSlice) SliceIntersect ¶
func (w *ToolsSlice) SliceIntersect(s1, s2 []interface{}) (s3 []interface{})
func (*ToolsSlice) SlicePad ¶
func (w *ToolsSlice) SlicePad(slice []interface{}, size int, val interface{}) []interface{}
func (*ToolsSlice) SliceRand ¶
func (w *ToolsSlice) SliceRand(a []interface{}) (b interface{})
func (*ToolsSlice) SliceRange ¶
func (w *ToolsSlice) SliceRange(start, end, step int64) (intSlice []int64)
func (*ToolsSlice) SliceReduce ¶
func (w *ToolsSlice) SliceReduce(s []interface{}, a reduceType) (s2 []interface{})
func (*ToolsSlice) SliceShuffle ¶
func (w *ToolsSlice) SliceShuffle(slice []interface{}) []interface{}
func (*ToolsSlice) SliceStr2SliceInt ¶
func (w *ToolsSlice) SliceStr2SliceInt(s []string) (ret []int)
func (*ToolsSlice) SliceSum ¶
func (w *ToolsSlice) SliceSum(s []int64) (sum int64)
func (*ToolsSlice) SliceUnique ¶
func (w *ToolsSlice) SliceUnique(slice []interface{}) (uniqueSlice []interface{})
Source Files ¶
- aes.go
- api_response.go
- email.go
- encry.go
- etcd.go
- gmap.go
- gorm.go
- httprequest.go
- jwt.go
- leveldb.go
- limit_counter.go
- limit_leaky_bucket.go
- limit_tocker_bucket.go
- logger.go
- map.go
- mongo.go
- oss.go
- redis.go
- regexp.go
- regexp_const.go
- slice.go
- string.go
- ticker.go
- time.go
- unpack.go
- validate_params.go
- viper.go
- wordsfilter.go
- xorm.go