update
This commit is contained in:
		| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : 任意类型之间的相互转换 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-02-23 10:23 下午 | ||||
| package convert | ||||
| @ -16,7 +16,7 @@ package convert | ||||
|  | ||||
|     代码中有一个Scaner接口,可以自行实现,然后通过"convertAssign()"函数,作为dst参数传入。 | ||||
|  | ||||
|    Author : zhangdeman001@ke.com<张德满> | ||||
|    Author : zhangdeman001@ke.com<白茶清欢> | ||||
|  | ||||
| */ | ||||
| import ( | ||||
|  | ||||
| @ -2,14 +2,14 @@ | ||||
| // | ||||
| // Description : easylock... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-02-24 6:29 下午 | ||||
| package easylock | ||||
|  | ||||
| // EasyLock ... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 4:18 下午 2021/4/1 | ||||
| type EasyLock interface { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : easylock ... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-04-01 4:13 下午 | ||||
| package easylock | ||||
| @ -13,14 +13,14 @@ type option struct { | ||||
|  | ||||
| // Option 设置option选项 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 4:15 下午 2021/4/1 | ||||
| type OptionFunc func(o *option) | ||||
|  | ||||
| // WithFlag 设置flag | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 4:17 下午 2021/4/1 | ||||
| func WithFlag(flag string) OptionFunc { | ||||
| @ -31,7 +31,7 @@ func WithFlag(flag string) OptionFunc { | ||||
|  | ||||
| // LockCnt 计数lockCnt | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 4:41 下午 2021/4/1 | ||||
| type LockCnt struct { | ||||
| @ -44,7 +44,7 @@ type base struct { | ||||
|  | ||||
| // ParseOption 解析option | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 4:24 下午 2021/4/1 | ||||
| func (b *base) ParseOption(optionFuncList ...OptionFunc) *option { | ||||
| @ -57,7 +57,7 @@ func (b *base) ParseOption(optionFuncList ...OptionFunc) *option { | ||||
|  | ||||
| // AddLockCnt 锁数量加一 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 4:44 下午 2021/4/1 | ||||
| func (b *base) AddLockCnt(lockCnt *LockCnt) { | ||||
| @ -66,7 +66,7 @@ func (b *base) AddLockCnt(lockCnt *LockCnt) { | ||||
|  | ||||
| // DecreaseLockCnt 锁数量 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 4:45 下午 2021/4/1 | ||||
| func (b *base) DecreaseLockCnt(lockCnt *LockCnt) { | ||||
| @ -75,7 +75,7 @@ func (b *base) DecreaseLockCnt(lockCnt *LockCnt) { | ||||
|  | ||||
| // AddRLockCnt 锁数量加一 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 4:44 下午 2021/4/1 | ||||
| func (b *base) AddRLockCnt(lockCnt *LockCnt) { | ||||
| @ -84,7 +84,7 @@ func (b *base) AddRLockCnt(lockCnt *LockCnt) { | ||||
|  | ||||
| // DecreaseRLockCnt 锁数量 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 4:45 下午 2021/4/1 | ||||
| func (b *base) DecreaseRLockCnt(lockCnt *LockCnt) { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : easylock... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-02-24 10:55 下午 | ||||
| package easylock | ||||
| @ -11,7 +11,7 @@ import "github.com/pkg/errors" | ||||
|  | ||||
| // segmentError ... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 1:44 下午 2021/2/24 | ||||
| func segmentError() error { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : 包装各种姿势的锁 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-02-24 6:26 下午 | ||||
| package easylock | ||||
| @ -11,7 +11,7 @@ import "sync" | ||||
|  | ||||
| // NewLock获取普通锁实例,因为只有一把锁,flag没有意义,传空即可 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:42 下午 2021/2/24 | ||||
| func NewLock() EasyLock { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : 分段的锁 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-02-24 10:44 下午 | ||||
| package easylock | ||||
| @ -11,7 +11,7 @@ import "git.zhangdeman.cn/zhangdeman/gopkg/util" | ||||
|  | ||||
| // NewSegment 获取分段锁 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 11:20 下午 2021/2/24 | ||||
| func NewSegment(segmentCnt int) (EasyLock, error) { | ||||
|  | ||||
| @ -2,14 +2,14 @@ | ||||
| // | ||||
| // Description : easymap... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-02-23 9:55 下午 | ||||
| package easymap | ||||
|  | ||||
| // EasyMap 约束各种数据接口的实现 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 9:56 下午 2021/2/23 | ||||
| type EasyMap interface { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : easymap... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-02-23 10:15 下午 | ||||
| package easymap | ||||
| @ -11,7 +11,7 @@ import "github.com/pkg/errors" | ||||
|  | ||||
| // keyNotFound key 不存在 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:17 下午 2021/2/23 | ||||
| func keyNotFound(key interface{}) error { | ||||
| @ -20,7 +20,7 @@ func keyNotFound(key interface{}) error { | ||||
|  | ||||
| // convertFail 数据类型妆换失败 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:28 下午 2021/2/23 | ||||
| func convertFail(err error) error { | ||||
| @ -29,7 +29,7 @@ func convertFail(err error) error { | ||||
|  | ||||
| // segmentError ... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 1:44 下午 2021/2/24 | ||||
| func segmentError() error { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : 普通的的map,增加锁支持 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-02-23 10:03 下午 | ||||
| package easymap | ||||
| @ -15,7 +15,7 @@ import ( | ||||
|  | ||||
| // NewNormal 获取map实例 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:07 下午 2021/2/23 | ||||
| func NewNormal(withLock bool) EasyMap { | ||||
| @ -31,7 +31,7 @@ func NewNormal(withLock bool) EasyMap { | ||||
|  | ||||
| // normal 普通map,内部可以加锁 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:03 下午 2021/2/23 | ||||
| type normal struct { | ||||
| @ -235,7 +235,7 @@ func (n *normal) Exist(key interface{}) bool { | ||||
|  | ||||
| // GetAll 读取全部数据使用的是原始数据深拷贝,避免获取到全部数据之后,直接读取导致并发读写 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:36 下午 2021/2/23 | ||||
| func (n *normal) GetAll() map[interface{}]interface{} { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : 分段存储的map,并发行更好,分段数量为 1, 将退化成普通的 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-02-23 10:47 下午 | ||||
| package easymap | ||||
| @ -13,7 +13,7 @@ import ( | ||||
|  | ||||
| // NewSegment 获取分段map实例 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 11:05 下午 2021/2/24 | ||||
| func NewSegment(segmentCnt int, withLock bool) (EasyMap, error) { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : 内置sync.Map + segment | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-02-24 2:08 下午 | ||||
| package easymap | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : easymap... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-02-24 5:57 下午 | ||||
| package easymap | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : 内置sync.Map + segment | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-02-24 2:08 下午 | ||||
| package easymap | ||||
| @ -13,7 +13,7 @@ import ( | ||||
|  | ||||
| // NewSegmentSync 获取SegmentSync实例 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 6:02 下午 2021/2/24 | ||||
| func NewSegmentSync(segment int) (EasyMap, error) { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : 便捷的相关API处理 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-03-26 2:06 下午 | ||||
| package api | ||||
| @ -13,7 +13,7 @@ import ( | ||||
|  | ||||
| // IApi 每一个接口的实现约束 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2:08 下午 2021/3/26 | ||||
| type IApi interface { | ||||
| @ -29,7 +29,7 @@ type IApi interface { | ||||
|  | ||||
| // RouterFunc 注册路由的函数 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 3:09 下午 2021/3/26 | ||||
| type RouterFunc func() (method string, uri string, handlerFunc gin.HandlerFunc, middlewareList []gin.HandlerFunc) | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : 注册路由 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-03-26 2:13 下午 | ||||
| package api | ||||
| @ -25,7 +25,7 @@ var ( | ||||
|  | ||||
| // DisableDebugLog 禁用debug日志 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2:17 下午 2021/3/26 | ||||
| func DisableDebugLog() { | ||||
| @ -34,7 +34,7 @@ func DisableDebugLog() { | ||||
|  | ||||
| // RegisterRouter 注册一个路由 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2:14 下午 2021/3/26 | ||||
| func RegisterRouter(router *gin.Engine, apiInstanceList ...interface{}) error { | ||||
| @ -106,7 +106,7 @@ func RegisterRouter(router *gin.Engine, apiInstanceList ...interface{}) error { | ||||
|  | ||||
| // routerLog 记录日志 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2:28 下午 2021/3/26 | ||||
| func routerLog(msg string) { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : 路由注册单元测试 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-03-26 3:49 下午 | ||||
| package api | ||||
| @ -18,7 +18,7 @@ import ( | ||||
|  | ||||
| // TestRegisterRouter ... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 3:50 下午 2021/3/26 | ||||
| func TestRegisterRouter(t *testing.T) { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : middleware... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-03-09 5:52 下午 | ||||
| package middleware | ||||
| @ -16,7 +16,7 @@ import ( | ||||
|  | ||||
| // InitRequest 初始化请求信息,统一设置请求时间/请求ID等信息 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 5:53 下午 2021/3/9 | ||||
| func InitRequest() func(ctx *gin.Context) { | ||||
|  | ||||
| @ -54,7 +54,7 @@ func ParseGetRequestURI(url *url.URL) map[string][]string { | ||||
|  | ||||
| // ParseGetRequestBody 解析get请求的body | ||||
| // | ||||
| // Author : zhangdeman001@ke.com<张德满> | ||||
| // Author : zhangdeman001@ke.com<白茶清欢> | ||||
| // | ||||
| // Date : 9:07 下午 2021/7/24 | ||||
| func ParseGetRequestBody(ctx *gin.Context) { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : request... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-07-24 9:21 下午 | ||||
| package request | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : 结合gin框架的一些工具集 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-03-09 4:51 下午 | ||||
| package util | ||||
| @ -18,7 +18,7 @@ import ( | ||||
|  | ||||
| // Response 向客户端响应数据 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 4:52 下午 2021/3/9 | ||||
| func Response(ctx *gin.Context, code interface{}, message string, data interface{}) { | ||||
| @ -34,7 +34,7 @@ func Response(ctx *gin.Context, code interface{}, message string, data interface | ||||
|  | ||||
| // RegisterRouter 注册gin路由 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 8:36 下午 2021/3/9 | ||||
| func RegisterRouter(router *gin.Engine, method string, uri string, handler gin.HandlerFunc, middlewareList []gin.HandlerFunc) error { | ||||
| @ -67,7 +67,7 @@ func RegisterRouter(router *gin.Engine, method string, uri string, handler gin.H | ||||
|  | ||||
| // RegisterRouterGroup 注册gin路由 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 8:36 下午 2021/3/9 | ||||
| func RegisterRouterGroup(router *gin.RouterGroup, method string, uri string, handler gin.HandlerFunc) error { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : 动态构建json | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-03-10 10:26 下午 | ||||
| package json | ||||
| @ -24,7 +24,7 @@ const ( | ||||
|  | ||||
| // JSONode JSOM节点 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:33 下午 2021/3/10 | ||||
| type JSONode struct { | ||||
| @ -42,7 +42,7 @@ type JSONode struct { | ||||
|  | ||||
| // NewDynamicJSON 获取JSON实例 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:36 下午 2021/3/10 | ||||
| func NewDynamicJSON() *DynamicJSON { | ||||
| @ -62,7 +62,7 @@ func NewDynamicJSON() *DynamicJSON { | ||||
|  | ||||
| // DynamicJSON 动态json | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 11:03 下午 2021/3/10 | ||||
| type DynamicJSON struct { | ||||
| @ -74,7 +74,7 @@ type DynamicJSON struct { | ||||
|  | ||||
| // SetValue 设置节点值,如果节点不存在,创建;如果已存在,更新, 多级key使用, value 必须是基础数据类型, 如果是结构体, 需要继续添加path,多级path使用.分割 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:45 下午 2021/3/10 | ||||
| func (dj *DynamicJSON) SetValue(path string, value interface{}, isComplexType bool) { | ||||
| @ -102,7 +102,7 @@ func (dj *DynamicJSON) SetValue(path string, value interface{}, isComplexType bo | ||||
|  | ||||
| // String 获取字符串的格式JSON | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2:16 下午 2021/3/11 | ||||
| func (dj *DynamicJSON) String() string { | ||||
| @ -114,7 +114,7 @@ func (dj *DynamicJSON) String() string { | ||||
|  | ||||
| // buildTpl 构建json模版与绑定数据 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 4:38 下午 2021/3/11 | ||||
| func (dj *DynamicJSON) buildTpl(root *JSONode, tplList *[]string, valList *[]interface{}) (*[]string, *[]interface{}) { | ||||
| @ -151,7 +151,7 @@ func (dj *DynamicJSON) buildTpl(root *JSONode, tplList *[]string, valList *[]int | ||||
|  | ||||
| // getValFormat 构建值得占位符 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 12:49 下午 2021/3/13 | ||||
| func (dj *DynamicJSON) getValFormat(root *JSONode) string { | ||||
| @ -181,7 +181,7 @@ func (dj *DynamicJSON) getValFormat(root *JSONode) string { | ||||
|  | ||||
| // getStartSymbol 计算起始的符号 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 12:21 下午 2021/3/13 | ||||
| func (dj *DynamicJSON) getStartSymbol(root *JSONode) string { | ||||
| @ -216,7 +216,7 @@ func (dj *DynamicJSON) getStartSymbol(root *JSONode) string { | ||||
|  | ||||
| // getEndSymbol 计算结束的符号 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 12:21 下午 2021/3/13 | ||||
| func (dj *DynamicJSON) getEndSymbol(root *JSONode) string { | ||||
| @ -246,7 +246,7 @@ func (dj *DynamicJSON) getEndSymbol(root *JSONode) string { | ||||
|  | ||||
| // Search 搜索一个key TODO : 优化 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 11:19 下午 2021/3/10 | ||||
| func (dj *DynamicJSON) search(root *JSONode, key string) *JSONode { | ||||
| @ -266,7 +266,7 @@ func (dj *DynamicJSON) search(root *JSONode, key string) *JSONode { | ||||
|  | ||||
| // createNode 创建新的节点 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:57 下午 2021/3/10 | ||||
| func (dj *DynamicJSON) createNode(parent *JSONode, key string, value interface{}, isComplexType bool) error { | ||||
| @ -309,7 +309,7 @@ func (dj *DynamicJSON) createNode(parent *JSONode, key string, value interface{} | ||||
|  | ||||
| // extraSliceIndex 抽取slice索引 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 9:37 下午 2021/3/11 | ||||
| func (dj *DynamicJSON) extraSliceIndex(key string) (bool, int) { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : json... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-03-10 11:44 下午 | ||||
| package json | ||||
| @ -14,7 +14,7 @@ import ( | ||||
|  | ||||
| // TestJSON ... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:58 下午 2021/3/14 | ||||
| func TestJSON(t *testing.T) { | ||||
| @ -42,7 +42,7 @@ func TestJSON(t *testing.T) { | ||||
|  | ||||
| // TestType 判断数据类型断言 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:59 下午 2021/3/14 | ||||
| func TestType(t *testing.T) { | ||||
| @ -51,7 +51,7 @@ func TestType(t *testing.T) { | ||||
|  | ||||
| // TestSelect 测试动态选择字段 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 9:47 下午 2021/4/13 | ||||
| func TestSelect(t *testing.T) { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : 将复杂数据结构转化为 JSONNode 树 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-03-14 10:40 下午 | ||||
| package json | ||||
| @ -22,7 +22,7 @@ import ( | ||||
|  | ||||
| // NewParseJSONTree 获取解析的实例 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:43 下午 2021/3/14 | ||||
| func NewParseJSONTree(data interface{}) *ParseJSONTree { | ||||
| @ -31,7 +31,7 @@ func NewParseJSONTree(data interface{}) *ParseJSONTree { | ||||
|  | ||||
| // ParseJSONTree 解析json树 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:41 下午 2021/3/14 | ||||
| type ParseJSONTree struct { | ||||
| @ -40,7 +40,7 @@ type ParseJSONTree struct { | ||||
|  | ||||
| // Parse 解析数据 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:44 下午 2021/3/14 | ||||
| func (pjt *ParseJSONTree) Parse(pathList []string) (*DynamicJSON, error) { | ||||
| @ -77,7 +77,7 @@ func (pjt *ParseJSONTree) Parse(pathList []string) (*DynamicJSON, error) { | ||||
|  | ||||
| // isLegalData 判断是否能转换成json结构, 只有slice/map/struct/能转换成slice或map的[]byte是合法的 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:46 下午 2021/3/14 | ||||
| func (pjt *ParseJSONTree) isLegalData() bool { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : config 日志配置 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-01-02 3:07 下午 | ||||
| package logger | ||||
| @ -39,7 +39,7 @@ const ( | ||||
|  | ||||
| // RotateLogConfig 日志切割的配置 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 3:08 下午 2021/1/2 | ||||
| type RotateLogConfig struct { | ||||
| @ -54,14 +54,14 @@ type RotateLogConfig struct { | ||||
|  | ||||
| // SetRotateLogConfigOption 设置日志切割的选项 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 3:13 下午 2021/1/2 | ||||
| type SetRotateLogConfigFunc func(rlc *RotateLogConfig) | ||||
|  | ||||
| // WithTimeIntervalType 设置日志切割时间间隔 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 3:34 下午 2021/1/2 | ||||
| func WithTimeIntervalType(timeIntervalType TimeIntervalType) SetRotateLogConfigFunc { | ||||
| @ -72,7 +72,7 @@ func WithTimeIntervalType(timeIntervalType TimeIntervalType) SetRotateLogConfigF | ||||
|  | ||||
| // WithDivisionChar 设置分隔符 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 3:49 下午 2021/1/2 | ||||
| func WithDivisionChar(divisionChar string) SetRotateLogConfigFunc { | ||||
| @ -83,7 +83,7 @@ func WithDivisionChar(divisionChar string) SetRotateLogConfigFunc { | ||||
|  | ||||
| // WithMaxAge 设置日志保存时间 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 5:03 下午 2021/1/2 | ||||
| func WithMaxAge(maxAge time.Duration) SetRotateLogConfigFunc { | ||||
| @ -94,7 +94,7 @@ func WithMaxAge(maxAge time.Duration) SetRotateLogConfigFunc { | ||||
|  | ||||
| // NewRotateLogConfig 生成日志切割的配置 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 3:53 下午 2021/1/2 | ||||
| func NewRotateLogConfig(logPath string, logFile string, option ...SetRotateLogConfigFunc) (*RotateLogConfig, error) { | ||||
| @ -121,7 +121,7 @@ func NewRotateLogConfig(logPath string, logFile string, option ...SetRotateLogCo | ||||
|  | ||||
| // formatConfig 格式化配置 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 4:23 下午 2021/1/2 | ||||
| func formatConfig(c *RotateLogConfig) error { | ||||
| @ -188,7 +188,7 @@ const ( | ||||
|  | ||||
| // defaultTimeEncoder 默认的时间处理 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 11:53 下午 2021/1/2 | ||||
| func defaultTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder) { | ||||
| @ -200,7 +200,7 @@ func defaultTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder) { | ||||
|  | ||||
| // SecondTimeEncoder 秒级时间戳格式化 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 8:34 下午 2021/1/3 | ||||
| func SecondTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder) { | ||||
| @ -209,7 +209,7 @@ func SecondTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder) { | ||||
|  | ||||
| // MsTimeEncoder 毫秒时间格式化方法 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 8:35 下午 2021/1/3 | ||||
| func MsTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder) { | ||||
| @ -220,7 +220,7 @@ func MsTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder) { | ||||
|  | ||||
| // defaultEncodeDuration 默认的原始时间处理 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 11:56 下午 2021/1/2 | ||||
| func defaultEncodeDuration(d time.Duration, enc zapcore.PrimitiveArrayEncoder) { | ||||
| @ -229,7 +229,7 @@ func defaultEncodeDuration(d time.Duration, enc zapcore.PrimitiveArrayEncoder) { | ||||
|  | ||||
| // OptionLogger 日志配置的选项 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 11:41 下午 2021/1/2 | ||||
| type OptionLogger struct { | ||||
| @ -280,7 +280,7 @@ func WithEncoder(encoder zapcore.Encoder) SetLoggerOptionFunc { | ||||
|  | ||||
| // WithUseJsonFormat 日志是否使用json格式数据 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 12:30 上午 2021/1/3 | ||||
| func WithUseJsonFormat(isJsonFormat bool) SetLoggerOptionFunc { | ||||
| @ -291,7 +291,7 @@ func WithUseJsonFormat(isJsonFormat bool) SetLoggerOptionFunc { | ||||
|  | ||||
| // WithMessageKey 使用message key | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 12:32 上午 2021/1/3 | ||||
| func WithMessageKey(messageKey string) SetLoggerOptionFunc { | ||||
| @ -306,7 +306,7 @@ func WithMessageKey(messageKey string) SetLoggerOptionFunc { | ||||
|  | ||||
| // WithLevelKey 设置level key | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 12:33 上午 2021/1/3 | ||||
| func WithLevelKey(levelKey string) SetLoggerOptionFunc { | ||||
| @ -321,7 +321,7 @@ func WithLevelKey(levelKey string) SetLoggerOptionFunc { | ||||
|  | ||||
| // WithTimeKey 设置time key ... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 12:34 上午 2021/1/3 | ||||
| func WithTimeKey(timeKey string) SetLoggerOptionFunc { | ||||
| @ -336,7 +336,7 @@ func WithTimeKey(timeKey string) SetLoggerOptionFunc { | ||||
|  | ||||
| // WithCallerKey 设置caller key | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 12:37 上午 2021/1/3 | ||||
| func WithCallerKey(callerKey string) SetLoggerOptionFunc { | ||||
| @ -351,7 +351,7 @@ func WithCallerKey(callerKey string) SetLoggerOptionFunc { | ||||
|  | ||||
| // WithShortCaller 是否使用短caller格式 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 12:39 上午 2021/1/3 | ||||
| func WithShortCaller(useShortCaller bool) SetLoggerOptionFunc { | ||||
| @ -362,7 +362,7 @@ func WithShortCaller(useShortCaller bool) SetLoggerOptionFunc { | ||||
|  | ||||
| // WithTimeEncoder 设置格式化时间方法 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 12:41 上午 2021/1/3 | ||||
| func WithTimeEncoder(encoder zapcore.TimeEncoder) SetLoggerOptionFunc { | ||||
| @ -376,7 +376,7 @@ func WithTimeEncoder(encoder zapcore.TimeEncoder) SetLoggerOptionFunc { | ||||
|  | ||||
| // WithEncodeDuration 原始时间 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 12:42 上午 2021/1/3 | ||||
| func WithEncodeDuration(encoder zapcore.DurationEncoder) SetLoggerOptionFunc { | ||||
| @ -390,7 +390,7 @@ func WithEncodeDuration(encoder zapcore.DurationEncoder) SetLoggerOptionFunc { | ||||
|  | ||||
| // GetEncoder 获取空中台输出的encoder | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 6:24 下午 2021/1/2 | ||||
| func GetEncoder(option ...SetLoggerOptionFunc) zapcore.Encoder { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : logger... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-01-03 12:58 上午 | ||||
| package logger | ||||
| @ -14,7 +14,7 @@ import ( | ||||
|  | ||||
| // FormatJson 格式化输出json | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 1:06 上午 2021/1/3 | ||||
| func FormatJson(src interface{}) string { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : error 定义日志处理过程中的各种错误 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-01-02 2:44 下午 | ||||
| package logger | ||||
| @ -11,7 +11,7 @@ import "github.com/pkg/errors" | ||||
|  | ||||
| // CreateLogFileError 创建日志文件失败 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2:55 下午 2021/1/2 | ||||
| func CreateLogFileError(err error, logFilePath string) error { | ||||
| @ -20,7 +20,7 @@ func CreateLogFileError(err error, logFilePath string) error { | ||||
|  | ||||
| // LogPathEmptyError 日志路径为空 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 4:03 下午 2021/1/2 | ||||
| func LogPathEmptyError() error { | ||||
| @ -29,7 +29,7 @@ func LogPathEmptyError() error { | ||||
|  | ||||
| // CustomTimeIntervalError 自定义日志切割时间间隔错误 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 4:11 下午 2021/1/2 | ||||
| func CustomTimeIntervalError() error { | ||||
| @ -38,7 +38,7 @@ func CustomTimeIntervalError() error { | ||||
|  | ||||
| // DealLogPathError 日志路径处理异常 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 4:31 下午 2021/1/2 | ||||
| func DealLogPathError(err error, logPath string) error { | ||||
| @ -47,7 +47,7 @@ func DealLogPathError(err error, logPath string) error { | ||||
|  | ||||
| // LogSplitTypeError 日志切割类型错误 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 4:50 下午 2021/1/2 | ||||
| func LogSplitTypeError(splitType TimeIntervalType) error { | ||||
| @ -56,7 +56,7 @@ func LogSplitTypeError(splitType TimeIntervalType) error { | ||||
|  | ||||
| // CreateIOWriteError 创建日志实例失败 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 5:20 下午 2021/1/2 | ||||
| func CreateIOWriteError(err error) error { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : logger 日志文件 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-01-02 5:04 下午 | ||||
| package logger | ||||
| @ -22,7 +22,7 @@ import ( | ||||
|  | ||||
| // NewLogger 获取日志实例 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 5:05 下午 2021/1/2 | ||||
| func NewLogger(loggerLevel zapcore.Level, splitConfig *RotateLogConfig, optionFunc ...SetLoggerOptionFunc) (*zap.Logger, error) { | ||||
| @ -78,7 +78,7 @@ func NewLogger(loggerLevel zapcore.Level, splitConfig *RotateLogConfig, optionFu | ||||
|  | ||||
| // NewConsoleLogger 获取控制台输出的日志实例 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 8:22 下午 2021/4/17 | ||||
| func NewConsoleLogger(loggerLevel zapcore.Level, optionFunc ...SetLoggerOptionFunc) (*zap.Logger, error) { | ||||
| @ -115,7 +115,7 @@ type Logger struct { | ||||
|  | ||||
| // getWriter 获取日志实例 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 5:08 下午 2021/1/2 | ||||
| func (l *Logger) getWriter() (io.Writer, error) { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : logger_test 单元测试 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-01-02 4:59 下午 | ||||
| package logger | ||||
| @ -19,7 +19,7 @@ import ( | ||||
|  | ||||
| // Test_Logger ... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 5:50 下午 2021/1/2 | ||||
| func Test_Logger(t *testing.T) { | ||||
| @ -41,7 +41,7 @@ func Test_Logger(t *testing.T) { | ||||
|  | ||||
| // Test_FormatJson 测试json格式化输出 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 1:08 上午 2021/1/3 | ||||
| func Test_FormatJson(t *testing.T) { | ||||
| @ -59,7 +59,7 @@ func Test_FormatJson(t *testing.T) { | ||||
|  | ||||
| // Test_Time 测试格式化纳秒时间戳 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 8:32 下午 2021/1/3 | ||||
| func Test_Time(t *testing.T) { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : gorm v2 版本接口实现 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-03-01 9:52 下午 | ||||
| package wrapper | ||||
| @ -24,7 +24,7 @@ import ( | ||||
|  | ||||
| // NewGormV2 获取日志实例 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 9:56 下午 2021/3/1 | ||||
| func NewGormV2(loggerLevel zapcore.Level, consoleOutput bool, encoder zapcore.Encoder, splitConfig *logger2.RotateLogConfig, traceIDField string, skip int) (logger.Interface, error) { | ||||
| @ -47,7 +47,7 @@ func NewGormV2(loggerLevel zapcore.Level, consoleOutput bool, encoder zapcore.En | ||||
|  | ||||
| // Gorm v2 版本库日志实现 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 9:55 下午 2021/3/1 | ||||
| type Gorm struct { | ||||
| @ -58,7 +58,7 @@ type Gorm struct { | ||||
|  | ||||
| // LogMode ... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:08 下午 2021/3/1 | ||||
| func (g *Gorm) LogMode(level logger.LogLevel) logger.Interface { | ||||
| @ -67,7 +67,7 @@ func (g *Gorm) LogMode(level logger.LogLevel) logger.Interface { | ||||
|  | ||||
| // Info 日志 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:18 下午 2021/3/1 | ||||
| func (g *Gorm) Info(ctx context.Context, s string, i ...interface{}) { | ||||
| @ -81,7 +81,7 @@ func (g *Gorm) Info(ctx context.Context, s string, i ...interface{}) { | ||||
|  | ||||
| // Warn ... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:16 下午 2021/3/1 | ||||
| func (g *Gorm) Warn(ctx context.Context, s string, i ...interface{}) { | ||||
| @ -95,7 +95,7 @@ func (g *Gorm) Warn(ctx context.Context, s string, i ...interface{}) { | ||||
|  | ||||
| // Error 日志 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:18 下午 2021/3/1 | ||||
| func (g *Gorm) Error(ctx context.Context, s string, i ...interface{}) { | ||||
| @ -109,7 +109,7 @@ func (g *Gorm) Error(ctx context.Context, s string, i ...interface{}) { | ||||
|  | ||||
| // Trace Trace 记录 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:19 下午 2021/3/1 | ||||
| func (g *Gorm) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error) { | ||||
| @ -136,7 +136,7 @@ func (g *Gorm) Trace(ctx context.Context, begin time.Time, fc func() (string, in | ||||
|  | ||||
| // getTraceID 获取traceID | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:11 下午 2021/3/1 | ||||
| func (g *Gorm) getTraceID(ctx context.Context) string { | ||||
| @ -145,7 +145,7 @@ func (g *Gorm) getTraceID(ctx context.Context) string { | ||||
|  | ||||
| // GetGormSQL 获取tracefn | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:38 下午 2021/3/1 | ||||
| func GetGormSQL(dbClient *gorm.DB) func() (string, int64) { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : http_gin 使用gin框架时的,记录日志 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-01-03 3:43 下午 | ||||
| package wrapper | ||||
| @ -19,7 +19,7 @@ import ( | ||||
|  | ||||
| // NewGinLogger 使用gin框架记录日志 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 3:45 下午 2021/1/3 | ||||
| func NewGinLogger(loggerLevel zapcore.Level, consoleOutput bool, encoder zapcore.Encoder, splitConfig *logger.RotateLogConfig, extractFieldList []string, skip int) (*Gin, error) { | ||||
| @ -43,7 +43,7 @@ func NewGinLogger(loggerLevel zapcore.Level, consoleOutput bool, encoder zapcore | ||||
|  | ||||
| // Gin 包装gin实例 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 3:59 下午 2021/1/3 | ||||
| type Gin struct { | ||||
| @ -53,7 +53,7 @@ type Gin struct { | ||||
|  | ||||
| // formatFieldList 格式化日志field列表 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 4:13 下午 2021/1/3 | ||||
| func (gw *Gin) formatFieldList(ginCtx *gin.Context, inputFieldList []zap.Field) []zap.Field { | ||||
| @ -74,7 +74,7 @@ func (gw *Gin) formatFieldList(ginCtx *gin.Context, inputFieldList []zap.Field) | ||||
|  | ||||
| // Debug 日志 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 4:14 下午 2021/1/3 | ||||
| func (gw *Gin) Debug(ginCtx *gin.Context, msg string, field ...zap.Field) { | ||||
| @ -84,7 +84,7 @@ func (gw *Gin) Debug(ginCtx *gin.Context, msg string, field ...zap.Field) { | ||||
|  | ||||
| // Info 日志 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 4:28 下午 2021/1/3 | ||||
| func (gw *Gin) Info(ginCtx *gin.Context, msg string, field ...zap.Field) { | ||||
| @ -94,7 +94,7 @@ func (gw *Gin) Info(ginCtx *gin.Context, msg string, field ...zap.Field) { | ||||
|  | ||||
| // Warn 日志 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 4:29 下午 2021/1/3 | ||||
| func (gw *Gin) Warn(ginCtx *gin.Context, msg string, field ...zap.Field) { | ||||
| @ -104,7 +104,7 @@ func (gw *Gin) Warn(ginCtx *gin.Context, msg string, field ...zap.Field) { | ||||
|  | ||||
| // Error 日志 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 4:29 下午 2021/1/3 | ||||
| func (gw *Gin) Error(ginCtx *gin.Context, msg string, field ...zap.Field) { | ||||
| @ -114,7 +114,7 @@ func (gw *Gin) Error(ginCtx *gin.Context, msg string, field ...zap.Field) { | ||||
|  | ||||
| // Panic 日志 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 4:29 下午 2021/1/3 | ||||
| func (gw *Gin) Panic(ginCtx *gin.Context, msg string, field ...zap.Field) { | ||||
| @ -124,7 +124,7 @@ func (gw *Gin) Panic(ginCtx *gin.Context, msg string, field ...zap.Field) { | ||||
|  | ||||
| // DPanic 日志 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 4:30 下午 2021/1/3 | ||||
| func (gw *Gin) DPanic(ginCtx *gin.Context, msg string, field ...zap.Field) { | ||||
| @ -134,7 +134,7 @@ func (gw *Gin) DPanic(ginCtx *gin.Context, msg string, field ...zap.Field) { | ||||
|  | ||||
| // GetZapLoggerInstance 获取zap日志实例 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021/01/03 22:56:47 | ||||
| func (gw *Gin) GetZapLoggerInstance() *zap.Logger { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : mysql客户端 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-03-01 9:20 下午 | ||||
| package mysql | ||||
| @ -18,7 +18,7 @@ import ( | ||||
|  | ||||
| // GetDatabaseClient 获取日志实例 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:49 下午 2021/3/1 | ||||
| func GetDatabaseClient(conf *DBConfig, logConf *LogConfig) (*gorm.DB, error) { | ||||
| @ -49,7 +49,7 @@ func GetDatabaseClient(conf *DBConfig, logConf *LogConfig) (*gorm.DB, error) { | ||||
|  | ||||
| // buildConnectionDSN 构建建立连接的DSN | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 9:34 下午 2021/3/1 | ||||
| func buildConnectionDSN(conf *DBConfig) string { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : 数据定义 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-03-01 9:27 下午 | ||||
| package mysql | ||||
| @ -14,7 +14,7 @@ import ( | ||||
|  | ||||
| // DBConfig 数据库连接的配置 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 9:32 下午 2021/3/1 | ||||
| type DBConfig struct { | ||||
| @ -30,7 +30,7 @@ type DBConfig struct { | ||||
|  | ||||
| // LogConfig 日志配置 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:51 下午 2021/3/1 | ||||
| type LogConfig struct { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : 异常定义 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-03-01 9:42 下午 | ||||
| package mysql | ||||
| @ -11,7 +11,7 @@ import "github.com/pkg/errors" | ||||
|  | ||||
| // ConnectionOpenError 数据库连接失败 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 9:43 下午 2021/3/1 | ||||
| func ConnectionOpenError(err error) error { | ||||
| @ -20,7 +20,7 @@ func ConnectionOpenError(err error) error { | ||||
|  | ||||
| // CreateDBLogError 打开日志失败 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:53 下午 2021/3/1 | ||||
| func CreateDBLogError(err error) error { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : redis 客户端 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-02-27 4:49 下午 | ||||
| package redis | ||||
| @ -20,7 +20,7 @@ import ( | ||||
|  | ||||
| // defaultParseError ... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:59 下午 2021/2/27 | ||||
| func defaultParseError(err error) error { | ||||
| @ -44,7 +44,7 @@ func defaultParseError(err error) error { | ||||
|  | ||||
| // Options 连接选项,百分之百兼容第三方包的选项 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 4:57 下午 2021/2/27 | ||||
| type Options struct { | ||||
| @ -63,7 +63,7 @@ type RealClient struct { | ||||
|  | ||||
| // NewClient 获取redis client实例 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 5:05 下午 2021/2/27 | ||||
| func NewClient(config map[string]Options, parseErrorFunc func(err error) error) (ClientInterface, error) { | ||||
| @ -80,7 +80,7 @@ func NewClient(config map[string]Options, parseErrorFunc func(err error) error) | ||||
|  | ||||
| // Client 包装的redis client | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 4:52 下午 2021/2/27 | ||||
| type Client struct { | ||||
| @ -91,7 +91,7 @@ type Client struct { | ||||
|  | ||||
| // init 初始化redis连接 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 5:31 下午 2021/2/27 | ||||
| func (c *Client) init() error { | ||||
| @ -135,7 +135,7 @@ func (c *Client) init() error { | ||||
|  | ||||
| // getLogger ... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 7:07 下午 2021/2/27 | ||||
| func (c *Client) getLogger(conf *LoggerConfig) (*zap.Logger, error) { | ||||
| @ -152,7 +152,7 @@ func (c *Client) getLogger(conf *LoggerConfig) (*zap.Logger, error) { | ||||
|  | ||||
| // GetRedisClient 获取redis实例 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 5:16 下午 2021/2/27 | ||||
| func (c *Client) GetRedisClient(flag string) (*RealClient, error) { | ||||
| @ -165,7 +165,7 @@ func (c *Client) GetRedisClient(flag string) (*RealClient, error) { | ||||
|  | ||||
| // log 记录redis请求日志 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 8:52 下午 2021/2/27 | ||||
| func (c *Client) log(ctx *Context, realClient *RealClient, cmdResult redisInstance.Cmder, startTime int64, finishTime int64) { | ||||
| @ -183,7 +183,7 @@ func (c *Client) log(ctx *Context, realClient *RealClient, cmdResult redisInstan | ||||
|  | ||||
| // CommandProxy 执行命令的代理 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 9:41 下午 2021/2/27 | ||||
| func (c *Client) CommandProxy(ctx *Context, flag string, cmd string, param ...interface{}) (interface{}, error) { | ||||
| @ -210,7 +210,7 @@ func (c *Client) CommandProxy(ctx *Context, flag string, cmd string, param ...in | ||||
|  | ||||
| // CommandProxyWithReceiver 执行命令,并解析结果 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:00 下午 2021/2/27 | ||||
| func (c *Client) CommandProxyWithReceiver(ctx *Context, flag string, receiver interface{}, cmd string, param ...interface{}) error { | ||||
| @ -231,7 +231,7 @@ func (c *Client) CommandProxyWithReceiver(ctx *Context, flag string, receiver in | ||||
|  | ||||
| // ClientInterface 定义redis client的接口实现,方便单元测试数据mock | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:49 下午 2021/2/27 | ||||
| type ClientInterface interface { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : redis... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-02-27 8:22 下午 | ||||
| package redis | ||||
| @ -30,7 +30,7 @@ const ( | ||||
|  | ||||
| // Context 请求上下文 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 8:25 下午 2021/2/27 | ||||
| type Context struct { | ||||
| @ -44,7 +44,7 @@ type Context struct { | ||||
|  | ||||
| // NewContext 生成一个上下文 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 8:26 下午 2021/2/27 | ||||
| func NewContext(flag string, of ...SetContextFunc) *Context { | ||||
| @ -87,7 +87,7 @@ type SetContextFunc func(rc *Context) | ||||
|  | ||||
| // WithCtx 设置context | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 8:30 下午 2021/2/27 | ||||
| func WithCtx(ctx context.Context) SetContextFunc { | ||||
| @ -98,7 +98,7 @@ func WithCtx(ctx context.Context) SetContextFunc { | ||||
|  | ||||
| // WithGinCtx 设置gin上下文 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 8:34 下午 2021/2/27 | ||||
| func WithGinCtx(ginCtx *gin.Context) SetContextFunc { | ||||
| @ -109,7 +109,7 @@ func WithGinCtx(ginCtx *gin.Context) SetContextFunc { | ||||
|  | ||||
| // WithExtra 设置扩展信息 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 8:36 下午 2021/2/27 | ||||
| func WithExtra(extra easymap.EasyMap) SetContextFunc { | ||||
| @ -120,7 +120,7 @@ func WithExtra(extra easymap.EasyMap) SetContextFunc { | ||||
|  | ||||
| // WithRequestIDField 设置request_id参数名 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 8:41 下午 2021/2/27 | ||||
| func WithRequestIDField(requestIDField string) SetContextFunc { | ||||
| @ -131,7 +131,7 @@ func WithRequestIDField(requestIDField string) SetContextFunc { | ||||
|  | ||||
| // WithRequestID ... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 8:42 下午 2021/2/27 | ||||
| func WithRequestID(requestID string) SetContextFunc { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : redis... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-02-27 5:13 下午 | ||||
| package redis | ||||
| @ -11,7 +11,7 @@ import "github.com/pkg/errors" | ||||
|  | ||||
| // FlagNotFound flag不存在异常 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 5:15 下午 2021/2/27 | ||||
| func FlagNotFound(flag string) error { | ||||
| @ -20,7 +20,7 @@ func FlagNotFound(flag string) error { | ||||
|  | ||||
| // LoggerInitFail 日志初始化失败 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 7:30 下午 2021/2/27 | ||||
| func LoggerInitFail(flag string, err error) error { | ||||
| @ -29,7 +29,7 @@ func LoggerInitFail(flag string, err error) error { | ||||
|  | ||||
| // EmptyCmd 未设置要执行的命令 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 9:46 下午 2021/2/27 | ||||
| func EmptyCmd() error { | ||||
| @ -38,7 +38,7 @@ func EmptyCmd() error { | ||||
|  | ||||
| // CommandExecuteFail 命令执行失败 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 9:58 下午 2021/2/27 | ||||
| func CommandExecuteFail(err error) error { | ||||
| @ -47,7 +47,7 @@ func CommandExecuteFail(err error) error { | ||||
|  | ||||
| // ReceiverISNIL 数据接收者是空指针 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:05 下午 2021/2/27 | ||||
| func ReceiverISNIL() error { | ||||
| @ -56,7 +56,7 @@ func ReceiverISNIL() error { | ||||
|  | ||||
| // ResultConvertFail 数据结果解析失败 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:07 下午 2021/2/27 | ||||
| func ResultConvertFail(err error) error { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : redis... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-02-27 5:26 下午 | ||||
| package redis | ||||
| @ -14,7 +14,7 @@ import ( | ||||
|  | ||||
| // LoggerConfig 日志配置 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 5:26 下午 2021/2/27 | ||||
| type LoggerConfig struct { | ||||
| @ -28,7 +28,7 @@ type LoggerConfig struct { | ||||
|  | ||||
| // LogFieldConfig 日志字段配置 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 9:20 下午 2021/2/27 | ||||
| type LogFieldConfig struct { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : redis... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-02-27 10:14 下午 | ||||
| package redis | ||||
| @ -18,7 +18,7 @@ import ( | ||||
|  | ||||
| // TestCommandProxy ... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:22 下午 2021/2/27 | ||||
| func TestCommandProxy(t *testing.T) { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : 按需返回对外暴露的字段 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-03-10 6:38 下午 | ||||
| package safe | ||||
| @ -15,7 +15,7 @@ import ( | ||||
|  | ||||
| // Filter 按需输出数据 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 6:40 下午 2021/3/10 | ||||
| func Filter(source []byte, filter []string) ([]byte, error) { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : safe... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-03-10 10:07 下午 | ||||
| package safe | ||||
|  | ||||
							
								
								
									
										14
									
								
								safe/ip.go
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								safe/ip.go
									
									
									
									
									
								
							| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : 安全策略之,访问黑名单 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-03-07 11:34 下午 | ||||
| package safe | ||||
| @ -14,14 +14,14 @@ import ( | ||||
|  | ||||
| // IPBlack ip黑名单 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 11:35 下午 2021/3/7 | ||||
| var IPBlack *ipBlack | ||||
|  | ||||
| // InitIPBlack 初始化ip黑名单 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 11:36 下午 2021/3/7 | ||||
| func InitIPBlack(ipList []string) error { | ||||
| @ -31,7 +31,7 @@ func InitIPBlack(ipList []string) error { | ||||
|  | ||||
| // InitIPBlackWithSeg ip黑名单分片存储 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 11:37 下午 2021/3/7 | ||||
| func InitIPBlackWithSeg(seg int, ipList []string) error { | ||||
| @ -53,7 +53,7 @@ type ipBlack struct { | ||||
|  | ||||
| // Add 添加黑名单IP | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 12:05 上午 2021/3/8 | ||||
| func (ib *ipBlack) Add(ip string) { | ||||
| @ -62,7 +62,7 @@ func (ib *ipBlack) Add(ip string) { | ||||
|  | ||||
| // Del 删除一个黑名单IP ... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 12:06 上午 2021/3/8 | ||||
| func (ib *ipBlack) Del(ip string) { | ||||
| @ -71,7 +71,7 @@ func (ib *ipBlack) Del(ip string) { | ||||
|  | ||||
| // IsBlack 判断ip是否存在于和名单之中 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 12:07 上午 2021/3/8 | ||||
| func (ib *ipBlack) IsBlack(ip string) bool { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : try... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-07-24 11:15 下午 | ||||
| package try | ||||
|  | ||||
							
								
								
									
										10
									
								
								util/file.go
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								util/file.go
									
									
									
									
									
								
							| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : 文件相关工具 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-04-26 6:00 下午 | ||||
| package util | ||||
| @ -18,7 +18,7 @@ import ( | ||||
|  | ||||
| // GetProjectPath 获取项目路径(可执行文件所在目录) | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:32 下午 2021/4/26 | ||||
| func GetProjectPath() (string, error) { | ||||
| @ -37,7 +37,7 @@ func GetProjectPath() (string, error) { | ||||
|  | ||||
| // ReadYmlConfig 读取yml配置问价,并解析到指定的结构体中 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:35 下午 2021/4/26 | ||||
| func ReadYmlConfig(filePath string, result interface{}) error { | ||||
| @ -56,7 +56,7 @@ func ReadYmlConfig(filePath string, result interface{}) error { | ||||
|  | ||||
| // ReadFileContent 读取文件内容 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:37 下午 2021/4/26 | ||||
| func ReadFileContent(filePath string) ([]byte, error) { | ||||
| @ -78,7 +78,7 @@ func ReadFileContent(filePath string) ([]byte, error) { | ||||
|  | ||||
| // IsFileExist 判断文件是否存在 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 10:37 下午 2021/4/26 | ||||
| func IsFileExist(filePath string) (bool, bool) { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : util... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-02-24 11:04 下午 | ||||
| package util | ||||
| @ -15,7 +15,7 @@ import ( | ||||
|  | ||||
| // GetHashID ... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 11:04 下午 2021/2/24 | ||||
| func GetHashID(key interface{}) uint64 { | ||||
| @ -24,7 +24,7 @@ func GetHashID(key interface{}) uint64 { | ||||
|  | ||||
| // GetHashIDMod 获取hashID并取模 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 11:07 下午 2021/2/24 | ||||
| func GetHashIDMod(key interface{}, shard int) int { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : util... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-03-09 5:56 下午 | ||||
| package util | ||||
| @ -11,7 +11,7 @@ import "net" | ||||
|  | ||||
| // GetHostIP 获取本机IP地址 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 5:58 下午 2021/3/9 | ||||
| func GetHostIP() string { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : 字符串相关的工具 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-03-09 6:00 下午 | ||||
| package util | ||||
| @ -16,7 +16,7 @@ import ( | ||||
|  | ||||
| // GenRandomString 获取随机长度的字符串 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 6:01 下午 2021/3/9 | ||||
| func GenRandomString(source string, length uint) string { | ||||
| @ -38,7 +38,7 @@ func GenRandomString(source string, length uint) string { | ||||
|  | ||||
| // Md5 对字符串进行md5加密 | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 6:01 下午 2021/3/9 | ||||
| func Md5(str string) string { | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
| // | ||||
| // Description : util ... | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 2021-03-14 11:11 下午 | ||||
| package util | ||||
| @ -11,7 +11,7 @@ import "encoding/json" | ||||
|  | ||||
| // StructToMap 结构体转为map | ||||
| // | ||||
| // Author : go_developer@163.com<张德满> | ||||
| // Author : go_developer@163.com<白茶清欢> | ||||
| // | ||||
| // Date : 11:12 下午 2021/3/14 | ||||
| func StructToMap(data interface{}) (map[string]interface{}, error) { | ||||
|  | ||||
		Reference in New Issue
	
	Block a user