Documentation ¶
Index ¶
- Constants
- Variables
- func BJSNowDatetimeStr() string
- func BJSTodayDateStr() string
- func BytesMD5Hash(data []byte) string
- func CreateJWTToken(claims CustomJWTClaims, salt []byte) (string, error)
- func GenerateQrCode(content string, width, height int) ([]byte, error)
- func ListDirFiles(dirPath, suffix string) ([]string, error)
- func MakeExcelFp(data ...ExcelSheet) (*excelize.File, error)
- func MultiStringMD5Hash(data ...string) string
- func NowTimestamp() int64
- func PathOk(path string) (bool, error)
- func ReadCSV(filepath string) ([][]string, error)
- func RefreshJWTToken(tokenStr string, salt []byte, survivalTime time.Duration) (string, error)
- func SafeMakeExcelFp(data ...ExcelSheet) (*excelize.File, error)
- func SafeSliceString(data string, start, end int) (string, error)
- func StringContainsHan(data string) bool
- func StringContainsSpace(data string) bool
- func StringMD5Hash(data string) string
- func Time2BJS(value time.Time) time.Time
- func Timestamp2Datetime(timestamp int64, tz *time.Location) time.Time
- func Timestamp2DatetimeStr(timestamp int64, tz *time.Location) string
- func UTCNowDatetimeStr() string
- func UTCTodayDateStr() string
- func ValidFileUTF8(filepath string, checkLines int) (bool, error)
- type CustomJWTClaims
- type ExcelSheet
- type Level
- type RotateFileWriter
- type XLogger
- func (obj *XLogger) Debug(msg ...interface{})
- func (obj *XLogger) Error(msg ...interface{})
- func (obj *XLogger) Info(msg ...interface{})
- func (obj *XLogger) Level() Level
- func (obj *XLogger) Printf(format string, v ...interface{})
- func (obj *XLogger) SetLevel(level Level)
- func (obj *XLogger) Warn(msg ...interface{})
Constants ¶
const ExcelMaxRowCount = 1048576
Excel单个sheet最多只能有1048576行,超出的行数据将保存到复制了名称的sheet
Variables ¶
var ( TokenExpired = errors.New(" Token is expired") TokenNotValidYet = errors.New(" Token not active yet") TokenMalformed = errors.New(" That's not even a token") TokenInvalid = errors.New(" Couldn't handle this token:") )
Error notes
var BJS = time.FixedZone("BJS", 8*3600)
Set time zone at UTC/GMT+08:00, China Standard Time UTC+8:00
var ErrIndexOutOfRange = errors.New("the 'start' or 'end' index value is out of range")
var ErrStartLargeThenEnd = errors.New("the 'start' index value is over then 'end'")
var ExcelIllegalCharactersRe = regexp.MustCompile(`[\000-\010]|[\013-\014]|[\016-\037]`)
Functions ¶
func BJSNowDatetimeStr ¶
func BJSNowDatetimeStr() string
func BJSTodayDateStr ¶
func BJSTodayDateStr() string
func CreateJWTToken ¶
func CreateJWTToken(claims CustomJWTClaims, salt []byte) (string, error)
生成JWT TOKEN: claims 载体数据, salt加密盐值
func ListDirFiles ¶
获取目录下是所有文件的绝对路径(不含文件夹, 并且可以通过suffix过滤, 当suffix为空字符串或者"*"时表示配匹所有文件尾缀)
func MakeExcelFp ¶
func MakeExcelFp(data ...ExcelSheet) (*excelize.File, error)
func MultiStringMD5Hash ¶
Get the MD5 hash value of multi string
func NowTimestamp ¶
func NowTimestamp() int64
func RefreshJWTToken ¶
刷新JWT TOKEN tokenStr TOKEN字符串, salt加密盐值, survivalTime存活时间
func SafeMakeExcelFp ¶
func SafeMakeExcelFp(data ...ExcelSheet) (*excelize.File, error)
func SafeSliceString ¶
安全的切割字符串: data原字符串, start切片起点, end切片终点+1 Direct cutting of string may cause character scrambling, because some character could be 3 or 4 byte. Translate the 'string' into 'rune' before cutting could make safe
func UTCNowDatetimeStr ¶
func UTCNowDatetimeStr() string
func UTCTodayDateStr ¶
func UTCTodayDateStr() string
Types ¶
type CustomJWTClaims ¶
type CustomJWTClaims struct { CustomData interface{} `json:"custom_data"` jwt.StandardClaims }
自定义载体, CustomData用于保存自定义的数据; jwt.StandardClaims用于存储载体附属信息, 特别是过期时间
func ParseJWTToken ¶
func ParseJWTToken(tokenStr string, salt []byte) (*CustomJWTClaims, error)
解析JWT TOKEN: tokenStr TOKEN字符串, salt加密盐值
type ExcelSheet ¶
type ExcelSheet struct { Name string Content [][]interface{} // contains filtered or unexported fields }
func (*ExcelSheet) Len ¶
func (obj *ExcelSheet) Len() int
func (*ExcelSheet) Safe ¶
func (obj *ExcelSheet) Safe() []ExcelSheet
func (*ExcelSheet) SetSafeLimit ¶
func (obj *ExcelSheet) SetSafeLimit(n int)
type RotateFileWriter ¶
type RotateFileWriter struct {
// contains filtered or unexported fields
}
Custom rotate file writer.
func NewRotateFileWriter ¶
func NewRotateFileWriter(fileName, dirPath string, maxCount int, maxSize int64) *RotateFileWriter
循环文件写入器: fileName基本文件名, dirPath文件夹路径, maxCount最大文件数量, maxSize最大文件体积
func (*RotateFileWriter) Init ¶
func (obj *RotateFileWriter) Init()
Initial method, check whether the log dir existed and have history log files