Documentation ¶
Overview ¶
* @Author: calmwu * @Date: 2017-09-18 10:33:28 * @Last Modified by: calmwu * @Last Modified time: 2018-04-28 16:37:37 * @Comment:
* @Author: calmwu * @Date: 2017-09-19 16:27:11 * @Last Modified by: calmwu * @Last Modified time: 2017-09-23 11:45:05 * @Comment:
Index ¶
- Constants
- Variables
- func ArrayToString(a []int, delim string) string
- func CheckDir(dirPath string) error
- func ConvertHashToObj(m interface{}, rawVal interface{}, tagName string) error
- func ConvertToFloat64(i interface{}, defaultValue float64) (ret float64)
- func ConvertToInt(i interface{}, defaultValue int) int
- func ConvertToInt64(i interface{}, defaultValue int64) (ret int64)
- func ConvertToString(i interface{}, defaultValue string) (ret string)
- func Crc16(buf string) uint16
- func CreateZapLog(logFullName string, maxSize int, maxAge int, maxBackups int, compress bool, ...) *zap.SugaredLogger
- func DecryptCipherText(cipherBlock cipher.Block, cipherText []byte) ([]byte, error)
- func DumpStacks()
- func EncryptPlainText(cipherBlock cipher.Block, plainText []byte) ([]byte, error)
- func GenerateDHKey() (*dhkx.DHKey, error)
- func GenerateEncryptionKey(pub []byte, privateKey *dhkx.DHKey) ([]byte, error)
- func GetCallStack() string
- func GetClientAddrFromGin(c *gin.Context) string
- func GetDate() string
- func GetDateByLocation(location *time.Location) string
- func GetDateHour() string
- func GetDateNum(location *time.Location) int
- func GetDateNum2(now *time.Time) int
- func GetDayEndTimeLocal() time.Time
- func GetDayEndTimeUtc() time.Time
- func GetIPByIfname(ifname string) (*string, error)
- func GetMonthName(location *time.Location) int
- func GetMonthlyDayCount(year int, month int) int
- func GetNextDayStartTimeByLocation(location *time.Location) time.Time
- func GetNextDayStartTimeLocal() time.Time
- func GetNextDayStartTimeUtc() time.Time
- func GetTimeByTz(tz string) (*time.Time, error)
- func GetTimeStampMs() string
- func GetTimeStampSec() string
- func GetTypeName(obj interface{}) (name1, name2, name3 string)
- func GetWeekDay(location *time.Location) int32
- func GetWeekName(location *time.Location) int
- func GinRegisterWebModule(router *gin.Engine, webModule interface{}) error
- func HashStr2Uint32(s string) uint32
- func HashStr2Uint64(s string) uint64
- func InitDefaultZapLog(logFullName string, logLevel zapcore.Level)
- func InitLog(logFilefullPath string)
- func Join(a []interface{}, sep string) string
- func MapstructUnPackByJsonTag(m interface{}, rawVal interface{}) error
- func MkDir(dirPath string) error
- func NewCipherBlock(encryptionKey []byte) (cipher.Block, error)
- func NewError(args ...interface{}) error
- func NewSimpleLog(out io.Writer) *log.Logger
- func PathExist(path string) error
- func PrintPerformTimeConsuming(funcName string, startTime time.Time)
- func RandStringBytesMaskImpr(n int) string
- func RandomBytes(size int) ([]byte, error)
- func RandomInt(n int) int
- func RegisterModuleInterface(interfacePath InterfacePath, httpMethodType int, ...)
- func SeedMathRand()
- func SendResponse(c *gin.Context, res *ProtoResponseS)
- func SendResponseToClient(c *gin.Context, res *ProtoResponseS)
- func SetRecvBuf(c *net.TCPConn, recvBufSize int) error
- func ShortCallerWithClassFunctionEncoder(caller zapcore.EntryCaller, enc zapcore.PrimitiveArrayEncoder)
- func StrError(err error) string
- func TimeName(t time.Time) string
- func ZlibCompress(data []byte, compressLevel int) ([]byte, error)
- func ZlibDCompress(data []byte) ([]byte, error)
- type FactoryReferenceCountable
- type InterfacePath
- type LocalizedTime
- func (this *LocalizedTime) Clock(year int, month int, day int, hour int, minute int, sec int) (time.Time, error)
- func (this *LocalizedTime) GetLocale() *time.Location
- func (this *LocalizedTime) IsCurrentWeek(sec int64) bool
- func (this *LocalizedTime) IsTheSameWeek(secX int64, secY int64) bool
- func (this *LocalizedTime) IsToday(sec int64) bool
- func (this *LocalizedTime) IsYesterday(sec int64) bool
- func (this *LocalizedTime) NSecTimeStamp() int64
- func (this *LocalizedTime) Now() time.Time
- func (this *LocalizedTime) NowDate() (year int, month time.Month, day int)
- func (this *LocalizedTime) SecTimeStamp() int64
- func (this *LocalizedTime) SetLocale(loc string) error
- func (this *LocalizedTime) TodayClock(hour int, minute int, sec int) (time.Time, error)
- func (this *LocalizedTime) Unix(sec int64, nsec int64) time.Time
- func (this *LocalizedTime) UnixDate(sec int64, nsec int64) (year int, month time.Month, day int)
- type ProtoData
- type ProtoFailInfoS
- type ProtoRequestHeadS
- type ProtoRequestS
- type ProtoResponseHeadS
- type ProtoResponseS
- type ProtoReturnCode
- type ReferenceCountable
- type ReferenceCountedPool
- type ReferenceCounter
- type ResetReferenceCountable
- type WebItfResData
- type WebModuleInterfaceMeta
- type WebModuleMetas
Constants ¶
const ( SecondsPerMinute = 60 SecondsPerHour = 60 * 60 SecondsPerDay = 24 * SecondsPerHour SecondsPerWeek = 7 * SecondsPerDay )
const ( WEBMODULE_METAS = "ModuleMetas" HTTP_METHOD_GET = 0x0001 HTTP_METHOD_POST = 0x0002 HTTP_METHOD_PUT = 0x0004 HTTP_METHOD_DELETE = 0x0008 )
const (
HashSeed = 0
)
const (
KEY_BYTES_SIZE = 32
)
https://www.cnblogs.com/si812cn/archive/2009/11/26/1611272.html g是p的原根Diffie-Hellman密钥交换算法的有效性依赖于计算离散对数的难度。简言之,可以如下定义离散对数:首先定义一个素数p的原根,为其各次幂产生从1 到p-1的所有整数根,也就是说,如果a是素数p的一个原根,那么数值 a mod p, a2 mod p, ..., ap-1 mod p 是各不相同的整数,并且以某种排列方式组成了从1到p-1的所有整数。
Variables ¶
var ( ErrModuleKindIsNotStruct = errors.New("Module kind is not struct") ErrModuleMetaInfosNotExist = errors.New("Module Interface Metainfos not exist") ErrModuleMetaTypeInvalid = errors.New("Module meta type is not WebModuleInterfaceMeta") WebModuleInterfaceMetaType = reflect.TypeOf(c_978_WebModuleInterfaceMeta_Default) )
var (
GLog l4g.Logger = nil
)
var (
SeededSecurely bool
)
var (
ZLog *zap.SugaredLogger
)
Functions ¶
func ArrayToString ¶
func ConvertHashToObj ¶
func ConvertToFloat64 ¶
func ConvertToInt ¶
func ConvertToInt64 ¶
func ConvertToString ¶
func CreateZapLog ¶
func CreateZapLog(logFullName string, maxSize int, maxAge int, maxBackups int, compress bool, logLevel zapcore.Level) *zap.SugaredLogger
logFullName: dir/dir/dir/test.log maxSize: megabytes, default = 100 maxAge: 多少天之后变为old file maxBackups: old file备份数量 compress: old file是否压缩tgz logLevel: zapcore.DebugLevel
func DecryptCipherText ¶
in-place模式
func DumpStacks ¶
func DumpStacks()
func EncryptPlainText ¶
传入明文,返回密文
func GenerateEncryptionKey ¶
根据对方返回的kb计算加密密钥
func GetCallStack ¶
func GetCallStack() string
func GetClientAddrFromGin ¶
func GetDateByLocation ¶
func GetDateHour ¶
func GetDateHour() string
func GetDateNum ¶
func GetDateNum2 ¶
func GetDayEndTimeLocal ¶
func GetDayEndTimeUtc ¶
func GetIPByIfname ¶
func GetMonthName ¶
func GetNextDayStartTimeUtc ¶
func GetTimeStampMs ¶
func GetTimeStampMs() string
func GetTimeStampSec ¶
func GetTimeStampSec() string
func GetTypeName ¶
func GetTypeName(obj interface{}) (name1, name2, name3 string)
func GetWeekDay ¶
func GetWeekName ¶
func GinRegisterWebModule ¶
func HashStr2Uint32 ¶
func HashStr2Uint64 ¶
func InitDefaultZapLog ¶
func MapstructUnPackByJsonTag ¶
func MapstructUnPackByJsonTag(m interface{}, rawVal interface{}) error
func RandStringBytesMaskImpr ¶
func RandomBytes ¶
func RegisterModuleInterface ¶
func RegisterModuleInterface(interfacePath InterfacePath, httpMethodType int, handlerFunc func(*gin.Context), moduleMetas WebModuleMetas)
func SendResponse ¶
func SendResponse(c *gin.Context, res *ProtoResponseS)
func SendResponseToClient ¶
func SendResponseToClient(c *gin.Context, res *ProtoResponseS)
func ShortCallerWithClassFunctionEncoder ¶
func ShortCallerWithClassFunctionEncoder(caller zapcore.EntryCaller, enc zapcore.PrimitiveArrayEncoder)
func ZlibDCompress ¶
Types ¶
type FactoryReferenceCountable ¶
type FactoryReferenceCountable func(ReferenceCounter) ReferenceCountable
type LocalizedTime ¶
type LocalizedTime struct {
// contains filtered or unexported fields
}
var (
GLocalizedTime *LocalizedTime = new(LocalizedTime)
)
func (*LocalizedTime) Clock ¶
func (this *LocalizedTime) Clock(year int, month int, day int, hour int, minute int, sec int) (time.Time, error)
根据年月日时分秒返回time结构
func (*LocalizedTime) IsCurrentWeek ¶
func (this *LocalizedTime) IsCurrentWeek(sec int64) bool
func (*LocalizedTime) IsTheSameWeek ¶
func (this *LocalizedTime) IsTheSameWeek(secX int64, secY int64) bool
func (*LocalizedTime) IsToday ¶
func (this *LocalizedTime) IsToday(sec int64) bool
传入一个时间戳(秒),判断是不是今天
func (*LocalizedTime) IsYesterday ¶
func (this *LocalizedTime) IsYesterday(sec int64) bool
传入一个时间戳(秒),判断是不是昨天
func (*LocalizedTime) NowDate ¶
func (this *LocalizedTime) NowDate() (year int, month time.Month, day int)
获取当前日期(年,月,日)
func (*LocalizedTime) SetLocale ¶
func (this *LocalizedTime) SetLocale(loc string) error
设置本地区域,如"UTC"
func (*LocalizedTime) TodayClock ¶
根据当天的时分秒返回time结构
type ProtoData ¶
type ProtoData struct { InterfaceName string `json:"InterfaceName"` Params interface{} `json:"Params"` }
type ProtoFailInfoS ¶
type ProtoFailInfoS struct {
FailureReason string `json:"FailureReason"`
}
type ProtoRequestHeadS ¶
type ProtoRequestS ¶
type ProtoRequestS struct { ProtoRequestHeadS ReqData ProtoData `json:"ReqData"` }
func UnpackClientRequest ¶
func UnpackClientRequest(c *gin.Context) (*ProtoRequestS, error)
func UnpackRequest ¶
func UnpackRequest(c *gin.Context) *ProtoRequestS
type ProtoResponseHeadS ¶
type ProtoResponseHeadS struct { Version int `json:"Version"` TimeStamp int64 `json:"TimeStamp"` EventId int `json:"EventId"` ReturnCode ProtoReturnCode `json:"ReturnCode"` }
type ProtoResponseS ¶
type ProtoResponseS struct { ProtoResponseHeadS ResData ProtoData `json:"ResData"` }
func PostRequest ¶
func PostRequest(url string, req *ProtoRequestS) (*ProtoResponseS, error)
type ProtoReturnCode ¶
type ProtoReturnCode int
type ReferenceCountable ¶
type ReferenceCountable interface { SetInstance(i interface{}) IncrementReferenceCount() DecrementReferenceCount() }
type ReferenceCountedPool ¶
type ReferenceCountedPool struct {
// contains filtered or unexported fields
}
计数对象池
func NewReferenceCountedPool ¶
func NewReferenceCountedPool(factory FactoryReferenceCountable, reset ResetReferenceCountable) *ReferenceCountedPool
生成一个计数对象池
func (*ReferenceCountedPool) Get ¶
func (rcp *ReferenceCountedPool) Get() ReferenceCountable
func (*ReferenceCountedPool) Stats ¶
func (rcp *ReferenceCountedPool) Stats() map[string]interface{}
输出pool的统计
type ReferenceCounter ¶
type ReferenceCounter struct { Instance interface{} `sql:"-" json:"-" yaml:"-"` // contains filtered or unexported fields }
计数对象类型
func (ReferenceCounter) DecrementReferenceCount ¶
func (rc ReferenceCounter) DecrementReferenceCount()
func (ReferenceCounter) IncrementReferenceCount ¶
func (rc ReferenceCounter) IncrementReferenceCount()
func (*ReferenceCounter) SetInstance ¶
func (rc *ReferenceCounter) SetInstance(i interface{})
type ResetReferenceCountable ¶
type ResetReferenceCountable func(interface{}) error
type WebItfResData ¶
type WebItfResData struct { Param interface{} RetCode int }
func RequestPretreatment ¶
func RequestPretreatment(c *gin.Context, interfaceName string, realReqPtr interface{}) (*WebItfResData, webItfResponseFunc, error)
type WebModuleInterfaceMeta ¶
web接口方法的描述
type WebModuleMetas ¶
type WebModuleMetas map[InterfacePath]*WebModuleInterfaceMeta
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
* @Author: calmwu * @Date: 2017-11-21 14:52:04 * @Last Modified by: calmwu * @Last Modified time: 2017-11-21 17:27:18 * @Comment:
|
* @Author: calmwu * @Date: 2017-11-21 14:52:04 * @Last Modified by: calmwu * @Last Modified time: 2017-11-21 17:27:18 * @Comment: |