Documentation ¶
Index ¶
- Constants
- Variables
- func AesDecrypt(data, key []byte) (result []byte, err error)
- func AesDecryptWithIV(data, key, iv []byte) (result []byte, err error)
- func AesEncrypt(data, key []byte) (result []byte, err error)
- func AesEncryptWithIV(data, key, iv []byte) (result []byte, err error)
- func ByteSlice2String(bs []byte) (str string)
- func CreateDirIfAbsent(dir string) error
- func DebugEnabled() bool
- func Debugf(format string, params ...interface{})
- func ErrorEnabled() bool
- func Errorf(format string, params ...interface{})
- func ExtractRefTuple(obj interface{}) (val reflect.Value, ind reflect.Value, typ reflect.Type)
- func FileBasename(s string) string
- func FillSlice(num int, fillFunc func(index int))
- func Float32(p interface{}) (i float32, err error)
- func Float64(p interface{}) (i float64, err error)
- func Fnv32Hashcode(data string) int
- func GetFieldType(structObj interface{}, fieldIndex int) reflect.Type
- func GetFirstFieldType(structObj interface{}) reflect.Type
- func HasNil(args ...interface{}) bool
- func InfoEnabled() bool
- func Infof(format string, params ...interface{})
- func Int(p interface{}) (i int, err error)
- func Int64(p interface{}) (i int64, err error)
- func IsEmpty(strs ...string) bool
- func IsValNil(v interface{}) bool
- func IsValidServiceState(oldState ServiceState, newState ServiceState) bool
- func LoadConfig(config Configurer, addonConfig string, configDir string, pathes ...string) (err error)
- func LoadConfigWithLoader(loader ConfigLoader, config Configurer, addonConfig string, configDir string, ...) (err error)
- func LoadYAMLFromPath(filename string, target interface{}) error
- func LoadYAMl(data []byte, target interface{}) error
- func LoggerSync()
- func MGet(m map[string]interface{}, key string) interface{}
- func MGetInt32(m map[string]interface{}, key string) (int32, error)
- func MGetInt64(m map[string]interface{}, key string) (int64, error)
- func MGetString(m map[string]interface{}, key string) (string, error)
- func PKCS5Padding(ciphertext []byte, blockSize int) ([]byte, error)
- func PKCS5UnPadding(origData []byte) ([]byte, error)
- func Parse(conf interface{}) error
- func ParseFloat32(param string) (v float32, err error)
- func ParseFloat64(param string) (v float64, err error)
- func ParseInput(input string) (inputReader *os.File, err error)
- func ParseInputAndOutput(input, output string) (inputReader, outWriter *os.File, err error)
- func ParseInt(param string) (v int, err error)
- func ParseInt32(param string) (v int32, err error)
- func ParseInt64(param string) (v int64, err error)
- func ParseLocalTime(t string) (time.Time, error)
- func ParseLocatTimeWithFormat(format, t string) (time.Time, error)
- func PrintErrorMsgAndExit(msg string, err error)
- func ProcessFileLines(file string, lineFunc ProcessLineFunc)
- func ProcessLines(rd io.Reader, processFunc ProcessLineFunc)
- func RandomUUID() (uuid string)
- func RegValidatorNewer(name string, validator ValidatorNewer)
- func ServiceInit(service Service) bool
- func ServiceName(service Service) string
- func ServiceStart(service Service) bool
- func ServiceStop(service Service) bool
- func SetLogLevel(level LogLevel)
- func SplitTrimOmitEmpty(str, sep string) []string
- func StackTrace(all bool) string
- func String2ByteSlice(str string) (bs []byte)
- func ToSlice(num int, fillFunc func(index int, dest []interface{})) []interface{}
- func TrimOmitEmpty(str []string) []string
- func UnixMills(t time.Time) int64
- func UnixMillsTime(tmillis int64) time.Time
- func UnmarshalUseNumber(data []byte, v interface{}) error
- func ValidateAll(validateService ValidateService, nameAndValues ...*ValidatePair) error
- func WaitStop() os.Signal
- func WarnEnabled() bool
- func Warnf(format string, params ...interface{})
- type AppConfig
- type BaseService
- type BoolValidator
- type ConfigFileLoader
- type ConfigLoader
- type Configurer
- type CopyOnWriteMap
- type CopyOnWriteSlice
- type CurrentMap
- func (m *CurrentMap) Count() int
- func (m *CurrentMap) Get(key interface{}) (interface{}, bool)
- func (m *CurrentMap) Has(key interface{}) bool
- func (m *CurrentMap) IsEmpty() bool
- func (m CurrentMap) Items() map[interface{}]interface{}
- func (m CurrentMap) Iter() <-chan CurrentMapTuple
- func (m CurrentMap) IterBuffered() <-chan CurrentMapTuple
- func (m *CurrentMap) Remove(key interface{})
- func (m *CurrentMap) Set(key interface{}, value interface{})
- func (m *CurrentMap) SetIfAbsent(key interface{}, value interface{}) (success bool, preVal interface{})
- type CurrentMapTuple
- type Float32Validator
- type Float64Validator
- type Initable
- type Int32Slice
- type Int32Validator
- type Int64Slice
- type Int64Validator
- type IntSlice
- type LinkedMap
- type LogConfig
- type LogConfiger
- type LogLevel
- type Logger
- type MapEntry
- type NotEmptyValidator
- type PageParam
- type PageResult
- type PageResultItemsSetter
- type ProcessLineFunc
- type Query
- type RegExValidator
- type ResultSet
- type RuleConfig
- type RuleValidateService
- type RuntimeConfig
- type Service
- type ServiceState
- type Services
- type Shutdownhook
- type Status
- type StdLogger
- func (l *StdLogger) DebugEnabled() bool
- func (l *StdLogger) Debugf(format string, params ...interface{})
- func (l *StdLogger) ErrorEnabled() bool
- func (l *StdLogger) Errorf(format string, params ...interface{})
- func (l *StdLogger) InfoEnabled() bool
- func (l *StdLogger) Infof(format string, params ...interface{})
- func (l *StdLogger) SetLevel(level LogLevel)
- func (l *StdLogger) Sync()
- func (l *StdLogger) WarnEnabled() bool
- func (l *StdLogger) Warnf(format string, params ...interface{})
- type StrValidator
- func NewBoolValidator(conf map[string]string) StrValidator
- func NewFloat32Validator(conf map[string]string) StrValidator
- func NewFloat64Validator(conf map[string]string) StrValidator
- func NewInt32Validator(conf map[string]string) StrValidator
- func NewInt64Validator(conf map[string]string) StrValidator
- func NewNotEmptyValidator(conf map[string]string) StrValidator
- func NewRegexValidator(conf map[string]string) StrValidator
- func NewStrLenValidator(conf map[string]string) StrValidator
- func NewValidatorByConf(conf map[string]string) StrValidator
- type StringLenValidator
- type StringSlice
- func (p StringSlice) ToFloat32() ([]float32, error)
- func (p StringSlice) ToFloat64() ([]float64, error)
- func (p StringSlice) ToInt() ([]int, error)
- func (p StringSlice) ToInt16() ([]int16, error)
- func (p StringSlice) ToInt32() ([]int32, error)
- func (p StringSlice) ToInt64() ([]int64, error)
- func (p StringSlice) ToInt8() ([]int8, error)
- func (p StringSlice) ToInterface() []interface{}
- func (p StringSlice) ToNumber(typ interface{}) (interface{}, error)
- type StructCopier
- type ValidateConfigurer
- type ValidateError
- type ValidatePair
- type ValidateRule
- type ValidateRuleConfig
- type ValidateService
- type ValidatorNewer
- type ZapLogger
- func (l *ZapLogger) DebugEnabled() bool
- func (l *ZapLogger) Debugf(format string, params ...interface{})
- func (l *ZapLogger) ErrorEnabled() bool
- func (l *ZapLogger) Errorf(format string, params ...interface{})
- func (l *ZapLogger) InfoEnabled() bool
- func (l *ZapLogger) Infof(format string, params ...interface{})
- func (l *ZapLogger) SetLevel(level LogLevel)
- func (l *ZapLogger) Sync()
- func (l *ZapLogger) WarnEnabled() bool
- func (l *ZapLogger) Warnf(format string, params ...interface{})
Constants ¶
const ( EnvDev = "dev" EnvTest = "test" EnvProduction = "prod" )
定义环境的常量
const ( // FormatDefault 默认的日期时间格式 FormatDefault = "2006-01-02 15:04:05" // FormatYYYYMMDD 日期时间格式 FormatYYYYMMDD = "20060102 15:04:05" // FormatYMDH 日期格式 FormatYMDH = "2006010215" // FormatYMD 日期格式 FormatYMD = "2006-01-02" )
const ( VNOTEMPTY = "notempty" //无构建参数 VBOOL = "bool" VSTRLEN = "strlen" VINT32 = "i32" VINT64 = "i64" VFLOAT32 = "f32" VFLOAT64 = "f64" VREGEX = "regex" )
默认的构建器的名称
const (
EnvWorkfDir = "work_dir"
)
定义环境变量
const LF = '\n'
LF `\n`
Variables ¶
var LocalLocation = time.Now().Local().Location()
LocalLocation 本地时区
Functions ¶
func AesDecrypt ¶
AesDecrypt 对data用key解密,使用PKCS5 Padding
func AesDecryptWithIV ¶
AesDecryptWithIV 对data用key和iv解密加密,使用PKCS5 Padding
func AesEncrypt ¶
AesEncrypt 对data用key加密,使用PKCS5 Padding
func AesEncryptWithIV ¶
AesEncryptWithIV 对data用key加密,使用PKCS5 Padding
func ByteSlice2String ¶
ByteSlice2String convert []byte to string
func ExtractRefTuple ¶
ExtractRefTuple 抽取反射的val:ValueOf ,ind:Indirect,typ:ind.Type
func Fnv32Hashcode ¶
Fnv32Hashcode calculate abs hash code for data
func GetFieldType ¶
GetFieldType 取得structObje的指定字段的类型
func GetFirstFieldType ¶
GetFirstFieldType 取得structObj的第一个字段的类型
func IsValidServiceState ¶
func IsValidServiceState(oldState ServiceState, newState ServiceState) bool
IsValidServiceState 检查ServiceState的状态转移是否有效
func LoadConfig ¶
func LoadConfig(config Configurer, addonConfig string, configDir string, pathes ...string) (err error)
LoadConfig 从configDir目录下的多个path指定的YAML配置文件中加载配置
func LoadConfigWithLoader ¶
func LoadConfigWithLoader(loader ConfigLoader, config Configurer, addonConfig string, configDir string, pathes ...string) (err error)
LoadConfigWithLoader 使用指定的加载器加载配置
func LoadYAMLFromPath ¶
LoadYAMLFromPath 将YAML文件中的配置加载到到结构体target中
func MGetString ¶
MGetString get string from m
func PKCS5Padding ¶
PKCS5Padding pkcs5 padding
func PKCS5UnPadding ¶
PKCS5UnPadding pkcs5 unpadding
func ParseInput ¶
ParseInput 解析输入的文件
func ParseInputAndOutput ¶
ParseInputAndOutput 解析输入的文件
func ParseLocatTimeWithFormat ¶
ParseLocatTimeWithFormat 解析本地时间
func PrintErrorMsgAndExit ¶
PrintErrorMsgAndExit 打印信息并退出
func ProcessFileLines ¶ added in v1.1.10
func ProcessFileLines(file string, lineFunc ProcessLineFunc)
ProcessFileLines 按行处理文件
func ProcessLines ¶
func ProcessLines(rd io.Reader, processFunc ProcessLineFunc)
ProcessLines 按行从rd中读取数据,交由processFunc进行处理
func RegValidatorNewer ¶
func RegValidatorNewer(name string, validator ValidatorNewer)
RegValidatorNewer 根据名称注册验证器构建函数
func SplitTrimOmitEmpty ¶
SplitTrimOmitEmpty 对str按sep分隔,去掉为空的项
func String2ByteSlice ¶
String2ByteSlice convert string to []byte
func UnmarshalUseNumber ¶
UnmarshalUseNumber 使用UserNumber进行解析,避免int64被错误地转为float64
func ValidateAll ¶
func ValidateAll(validateService ValidateService, nameAndValues ...*ValidatePair) error
ValidateAll 验证所有的规则
Types ¶
type AppConfig ¶
type AppConfig struct { *LogConfig `yaml:"log"` *RuntimeConfig `yaml:"runtime"` *ValidateRuleConfig `yaml:"validates"` }
AppConfig 基础的应用配置
func (*AppConfig) GetLogConfig ¶
GetLogConfig impls LogConfiger
func (*AppConfig) GetValidateRuleConfig ¶
func (p *AppConfig) GetValidateRuleConfig() *ValidateRuleConfig
GetValidateRuleConfig implements ValidateConfiguer
type BaseService ¶
type BaseService struct { SName string //服务的名称 Order int // contains filtered or unexported fields }
BaseService 提供基本的Service接口实现
type BoolValidator ¶
type BoolValidator struct { }
BoolValidator bool验证
func (*BoolValidator) Validate ¶
func (p *BoolValidator) Validate(param string) bool
Validate 验证bool值
type ConfigFileLoader ¶
type ConfigFileLoader struct { }
ConfigFileLoader 从本地文件中加载配置
type ConfigLoader ¶
type ConfigLoader interface { Load(configPath string) (content []byte, err error) Exist(configPath string) (exist bool, err error) }
ConfigLoader 配置内容加载器
var ( //FileLoader 默认加载 FileLoader ConfigLoader = &ConfigFileLoader{} )
type CopyOnWriteMap ¶
type CopyOnWriteMap struct {
// contains filtered or unexported fields
}
CopyOnWriteMap copy on write map
func NewCopyOnWriteMap ¶
func NewCopyOnWriteMap() *CopyOnWriteMap
NewCopyOnWriteMap 创建CopyOnWriteMap
func (*CopyOnWriteMap) Get ¶
func (p *CopyOnWriteMap) Get(key interface{}) interface{}
Get 取得key对应的值
func (*CopyOnWriteMap) Put ¶
func (p *CopyOnWriteMap) Put(key interface{}, value interface{})
Put key及对应的value,如果key已经存在,则进行替换
func (*CopyOnWriteMap) PutIfAbsent ¶
func (p *CopyOnWriteMap) PutIfAbsent(key interface{}, value interface{}) error
PutIfAbsent put key及对应的value,如果key已经存在,不进行替换,并返回错误
type CopyOnWriteSlice ¶
type CopyOnWriteSlice struct {
// contains filtered or unexported fields
}
CopyOnWriteSlice copy on write slice
func NewCopyOnWriteSlice ¶
func NewCopyOnWriteSlice() *CopyOnWriteSlice
NewCopyOnWriteSlice 创建CopyOnWriteSlice
func (*CopyOnWriteSlice) Delete ¶
func (p *CopyOnWriteSlice) Delete(value interface{}) error
Delete 删除value
type CurrentMap ¶
type CurrentMap struct {
// contains filtered or unexported fields
}
CurrentMap A "thread" safe map of type interface{}:interface{},auto gen from concurrent_map_template.go
func NewCurrentMap ¶
func NewCurrentMap() *CurrentMap
NewCurrentMap Create a new concurrent map with 32 shards
func NewCurrentMapWithShard ¶
func NewCurrentMapWithShard(shardCount uint) *CurrentMap
NewCurrentMapWithShard Creates a new concurrent map.
func (*CurrentMap) Count ¶
func (m *CurrentMap) Count() int
Count Returns the number of elements within the map.
func (*CurrentMap) Get ¶
func (m *CurrentMap) Get(key interface{}) (interface{}, bool)
Get Retrieves an element from map under given key.
func (*CurrentMap) Has ¶
func (m *CurrentMap) Has(key interface{}) bool
Has Looks up an item under specified key
func (CurrentMap) Items ¶
func (m CurrentMap) Items() map[interface{}]interface{}
Items Returns all items as map[interface{}]interface{}
func (CurrentMap) Iter ¶
func (m CurrentMap) Iter() <-chan CurrentMapTuple
Iter Returns an iterator which could be used in a for range loop.
func (CurrentMap) IterBuffered ¶
func (m CurrentMap) IterBuffered() <-chan CurrentMapTuple
IterBuffered Returns a buffered iterator which could be used in a for range loop.
func (*CurrentMap) Remove ¶
func (m *CurrentMap) Remove(key interface{})
Remove an element from the map.
func (*CurrentMap) Set ¶
func (m *CurrentMap) Set(key interface{}, value interface{})
Set the given value under the specified key.
func (*CurrentMap) SetIfAbsent ¶
func (m *CurrentMap) SetIfAbsent(key interface{}, value interface{}) (success bool, preVal interface{})
SetIfAbsent the given value under the specified key if no value was associated with it.
type CurrentMapTuple ¶
type CurrentMapTuple struct { Key interface{} Val interface{} }
CurrentMapTuple Used by the Iter & IterBuffered functions to wrap two variables together over a channel,
type Float32Validator ¶
type Float32Validator struct {
// contains filtered or unexported fields
}
Float32Validator 32位浮点数验证
func (*Float32Validator) Validate ¶
func (p *Float32Validator) Validate(param string) bool
Validate 验证浮点数值
type Float64Validator ¶
type Float64Validator struct {
// contains filtered or unexported fields
}
Float64Validator 64位浮点数验证
func (*Float64Validator) Validate ¶
func (p *Float64Validator) Validate(param string) bool
Validate 验证浮点数值
type Initable ¶
type Initable interface { // Init 执行初始化操作,如果初始化失败,返回错误的原因 Init() error }
Initable 表示需要进行初始化
type Int32Slice ¶
type Int32Slice []int32
Int32Slice int32 slice
func (Int32Slice) Len ¶ added in v1.1.1
func (p Int32Slice) Len() int
func (Int32Slice) Less ¶ added in v1.1.1
func (p Int32Slice) Less(i, j int) bool
func (Int32Slice) Swap ¶ added in v1.1.1
func (p Int32Slice) Swap(i, j int)
func (Int32Slice) ToInterface ¶
func (p Int32Slice) ToInterface() []interface{}
ToInterface 转为interface slice
type Int32Validator ¶
type Int32Validator struct {
// contains filtered or unexported fields
}
Int32Validator 32位整数验证
func (*Int32Validator) Validate ¶
func (p *Int32Validator) Validate(param string) bool
Validate 验证整型值
type Int64Slice ¶
type Int64Slice []int64
Int64Slice int64 slice
func (Int64Slice) Len ¶ added in v1.1.1
func (p Int64Slice) Len() int
func (Int64Slice) Less ¶ added in v1.1.1
func (p Int64Slice) Less(i, j int) bool
func (Int64Slice) Swap ¶ added in v1.1.1
func (p Int64Slice) Swap(i, j int)
func (Int64Slice) ToInterface ¶
func (p Int64Slice) ToInterface() []interface{}
ToInterface 转为interface slice
type Int64Validator ¶
type Int64Validator struct {
// contains filtered or unexported fields
}
Int64Validator 64位整数验证
func (*Int64Validator) Validate ¶
func (p *Int64Validator) Validate(param string) bool
Validate 验证整型值
type IntSlice ¶
type IntSlice []int
IntSlice int slice
func (IntSlice) ToInterface ¶
func (p IntSlice) ToInterface() []interface{}
ToInterface 转为interface slice
type LinkedMap ¶
type LinkedMap struct {
// contains filtered or unexported fields
}
LinkedMap implements linked map
type LogConfig ¶
type LogConfig struct { Env string `yaml:"env"` FileName string `yaml:"file_name"` MaxSize int `yaml:"max_size"` MaxBackups int `yaml:"max_backups"` MaxAge int `yaml:"max_age"` NoCaller bool `yaml:"no_caller"` Level string `yaml:"level"` }
LogConfig 日志配置
type LogConfiger ¶
type LogConfiger interface {
GetLogConfig() *LogConfig
}
LogConfiger the log configer
type Logger ¶
type Logger interface { Debugf(format string, params ...interface{}) DebugEnabled() bool Infof(format string, params ...interface{}) InfoEnabled() bool Warnf(format string, params ...interface{}) WarnEnabled() bool Errorf(format string, params ...interface{}) ErrorEnabled() bool SetLevel(level LogLevel) Sync() }
Logger 日志记录接口
type MapEntry ¶
type MapEntry struct { Key interface{} Value interface{} }
MapEntry define map entry with key and value
type NotEmptyValidator ¶
type NotEmptyValidator struct { }
NotEmptyValidator 非空
func (*NotEmptyValidator) Validate ¶
func (p *NotEmptyValidator) Validate(param string) bool
Validate 验证字符串是否为空
type PageParam ¶
type PageParam struct { //页数,从1开始 Page int `json:"page"` //每页的条数,>0 PageSize int `json:"page_size"` //游标 Cursor int64 `json:"cursor"` }
PageParam 分页参数
type PageResult ¶
type PageResult struct { PageParam Total int64 `json:"total"` TotalPage int64 `json:"totalPage"` Items interface{} `json:"items"` }
PageResult 分页结果
func (*PageResult) SetData ¶
func (p *PageResult) SetData(data interface{}, itemsSetter PageResultItemsSetter)
SetData implements ResultSet.SetData
func (*PageResult) SetTotal ¶
func (p *PageResult) SetTotal(total int64)
SetTotal implements ResultSet.SetTotal
type PageResultItemsSetter ¶
PageResultItemsSetter 结果设置
type ProcessLineFunc ¶
ProcessLineFunc 行处理函数
type RegExValidator ¶
type RegExValidator struct {
// contains filtered or unexported fields
}
RegExValidator 正则表达式验证
func (*RegExValidator) Validate ¶
func (p *RegExValidator) Validate(param string) bool
Validate 正则表达式验证
type ResultSet ¶
type ResultSet interface { SetTotal(total int64) SetData(data interface{}, itemsSetter PageResultItemsSetter) GetItemsSetter() PageResultItemsSetter CalTotalPage() }
ResultSet is the result set with total and items
type RuleConfig ¶
type RuleConfig struct { Name string Desc string //规则描述 Validators []map[string]string //验证器列表,必须要有name }
RuleConfig 验证规则配置
type RuleValidateService ¶
type RuleValidateService struct { BaseService Config ValidateConfigurer `inject:"_"` // contains filtered or unexported fields }
RuleValidateService 根据规则进行的验证服务
func (*RuleValidateService) Init ¶
func (p *RuleValidateService) Init() error
Init implements Initable
type Service ¶
type Service interface { Initable // Name 取得服务名称 Name() string // Start 启动服务 Start() bool // 启动的次序 GetStartOrder() int // Stop 停止服务 Stop() bool // 停止的次序 GetStopOrder() int // State 服务的状态 State() ServiceState // contains filtered or unexported methods }
Service 统一的服务接口
type ServiceState ¶
type ServiceState uint32
ServiceState 表示服务的状态
const ( // NEW 新建“ NEW ServiceState = iota // INITED 初始化完毕 INITED // STARTING 正在启动 STARTING // RUNNING 正在运行 RUNNING // STOPPING 正在停止 STOPPING // TERMINATED 已经停止 TERMINATED // FAILED 失败 FAILED )
func (ServiceState) String ¶
func (p ServiceState) String() string
type Services ¶
type Services struct {
// contains filtered or unexported fields
}
Services 一组Service的集合
func NewServices ¶
NewServices 构建新的Service集合
type Shutdownhook ¶
Shutdownhook 停止hook
func NewShutdownhook ¶
func NewShutdownhook(sig ...os.Signal) *Shutdownhook
NewShutdownhook 创建一个Shutdownhook,sig是要监听的信号,默认会监听syscall.SIGINT,syscall.SIGTERM
func (*Shutdownhook) WaitShutdown ¶
func (p *Shutdownhook) WaitShutdown()
WaitShutdown 等待进程退出的信号,当收到进程退出的信号后,依次执行注册的hook函数
type StdLogger ¶
type StdLogger struct {
// contains filtered or unexported fields
}
StdLogger 使用标准库封装的logger
func (*StdLogger) DebugEnabled ¶ added in v1.1.3
DebugEnabled is debug enbale
func (*StdLogger) ErrorEnabled ¶ added in v1.1.3
ErrorEnabled error
func (*StdLogger) InfoEnabled ¶ added in v1.1.3
InfoEnabled is info enable
func (*StdLogger) WarnEnabled ¶ added in v1.1.3
WarnEnabled is warn enabled
type StrValidator ¶
StrValidator 字符串验证器
func NewBoolValidator ¶
func NewBoolValidator(conf map[string]string) StrValidator
NewBoolValidator 创建bool验证器
func NewFloat32Validator ¶
func NewFloat32Validator(conf map[string]string) StrValidator
NewFloat32Validator 创建float32验证,conf["min"],最小值;conf["max"],最大值
func NewFloat64Validator ¶
func NewFloat64Validator(conf map[string]string) StrValidator
NewFloat64Validator 创建float64验证,conf["min"],最小值;conf["max"],最大值
func NewInt32Validator ¶
func NewInt32Validator(conf map[string]string) StrValidator
NewInt32Validator 创建int32验证,conf["min"],最小值;conf["max"],最大值
func NewInt64Validator ¶
func NewInt64Validator(conf map[string]string) StrValidator
NewInt64Validator 创建int64验证,conf["min"],最小值;conf["max"],最大值
func NewNotEmptyValidator ¶
func NewNotEmptyValidator(conf map[string]string) StrValidator
NewNotEmptyValidator 创建非空验证器
func NewRegexValidator ¶
func NewRegexValidator(conf map[string]string) StrValidator
NewRegexValidator 创建正则表达式验证,conf["pattern"] 正则表达式
func NewStrLenValidator ¶
func NewStrLenValidator(conf map[string]string) StrValidator
NewStrLenValidator 创建字符串长度验证,conf["min"],最小值;conf["max"],最大值
func NewValidatorByConf ¶
func NewValidatorByConf(conf map[string]string) StrValidator
NewValidatorByConf 根据配置conf["name"]及其对应的参数构建验证器
type StringLenValidator ¶
type StringLenValidator struct {
// contains filtered or unexported fields
}
StringLenValidator 字符串长度验证
func (*StringLenValidator) Validate ¶
func (p *StringLenValidator) Validate(param string) bool
Validate 验证字符串的长度
type StringSlice ¶
type StringSlice []string
StringSlice string slice
func (StringSlice) ToFloat32 ¶
func (p StringSlice) ToFloat32() ([]float32, error)
ToFloat32 转为[]float32
func (StringSlice) ToFloat64 ¶
func (p StringSlice) ToFloat64() ([]float64, error)
ToFloat64 转为[]floa64t
func (StringSlice) ToInt16 ¶ added in v1.1.6
func (p StringSlice) ToInt16() ([]int16, error)
ToInt16 转为[]int16
func (StringSlice) ToInt8 ¶ added in v1.1.6
func (p StringSlice) ToInt8() ([]int8, error)
ToInt8 转为[]int8
func (StringSlice) ToInterface ¶
func (p StringSlice) ToInterface() []interface{}
ToInterface 转为interface slice
func (StringSlice) ToNumber ¶
func (p StringSlice) ToNumber(typ interface{}) (interface{}, error)
ToNumber 转为数字slice
type StructCopier ¶
type StructCopier func(from interface{}, to interface{}) (err error)
StructCopier struct结构拷贝
func NewStructCopier ¶
func NewStructCopier(from interface{}, to interface{}) (copier StructCopier, err error)
NewStructCopier 拷贝
type ValidateConfigurer ¶
type ValidateConfigurer interface {
GetValidateRuleConfig() *ValidateRuleConfig
}
ValidateConfigurer validateConfig
type ValidateError ¶
type ValidateError struct {
// contains filtered or unexported fields
}
ValidateError error
func (*ValidateError) Error ¶
func (p *ValidateError) Error() string
type ValidatePair ¶
ValidatePair 定义验证规则名称其需要验证的值
func NewValidatePair ¶
func NewValidatePair(name, value string) *ValidatePair
NewValidatePair create ValidatePair
func NewValidatePairMsg ¶
func NewValidatePairMsg(name, value, msg string) *ValidatePair
NewValidatePairMsg create ValidatePair with msg
type ValidateRule ¶
type ValidateRule struct {
// contains filtered or unexported fields
}
ValidateRule 定义验证规则
type ValidateRuleConfig ¶
type ValidateRuleConfig struct { Rules []RuleConfig SName string //服务的名称 // contains filtered or unexported fields }
ValidateRuleConfig 验证规则配置
func (*ValidateRuleConfig) NewService ¶
func (p *ValidateRuleConfig) NewService() Service
NewService 根据配置解析的结果创建验证服务
type ValidateService ¶
type ValidateService interface { Service //Validate 使用name指定验证规则,对value进行验证,验证通过返回nil,否则返回错误原因 Validate(name string, value string) error }
ValidateService 验证服务
type ValidatorNewer ¶
type ValidatorNewer func(conf map[string]string) StrValidator
ValidatorNewer 创建验证器的函数类型
type ZapLogger ¶
type ZapLogger struct {
// contains filtered or unexported fields
}
ZapLogger 使用zap封装的logger
func (*ZapLogger) DebugEnabled ¶ added in v1.1.3
DebugEnabled is debug enbale
func (*ZapLogger) ErrorEnabled ¶ added in v1.1.3
ErrorEnabled is info enbale
func (*ZapLogger) InfoEnabled ¶ added in v1.1.3
InfoEnabled is info enbale
func (*ZapLogger) WarnEnabled ¶ added in v1.1.3
WarnEnabled is info enbale