Categorygithub.com/kerbalwzy/kerbalwzygo
modulepackage
1.0.0
Repository: https://github.com/kerbalwzy/kerbalwzygo.git
Documentation: pkg.go.dev

# README

kerbalwzygo

个人使用Golang进行后端开发时封装的一些工具对象

这里封装都是写工具的初级原型, 具体融合到项目中时可能需要做一些修改

懒得封装到兼容性很高, 我个人认为纯粹调包开发非常无聊而且包内有些功能也用不上, 抽空自己造一造轮子其实挺有意思的


  • u_csv

    • func ReadCSV(filepath string) ([][]string, error) 读取CSV文件, 去除了空行
  • u_excel

    • ExcelIllegalCharactersRe 非法字符串正则匹配器
    • ExcelSheet 分页数据对象
    • func (obj *ExcelSheet) Len() int 获取数据行数
    • func (obj *ExcelSheet) SetSafeLimit(n int) 设置单页安全数据行数上限值(最大值=1048576)
    • func (obj *ExcelSheet) Safe() []ExcelSheet 将分页数据对象进行安全转换
    • func MakeExcelFp(data ...ExcelSheet) (*excelize.File, error) 创建Excel文件对象
    • func SafeMakeExcelFp(data ...ExcelSheet) (*excelize.File, error) 安全的创建Excel文件对象
  • u_file

    • func PathOk(path string) (bool, error) 判断文件或者文件夹路径是否正常
    • func ValidFileUTF8(filepath string, checkLines int) (bool, error) 验证文件是否能被UTF8解码
    • func ListDirFiles(dirPath, suffix string) ([]string, error) 获取目录下是所有文件的绝对路径(不含文件夹, 并且可以通过suffix过滤, 当suffix为空字符串或者"*"时表示配匹所有文件尾缀)
  • u_jwt

    • type CustomJWTClaims struct 自定义JWT数据载体
    • func CreateJWTToken(claims CustomJWTClaims, salt []byte) (string, error) 创建JWT-Token字符串
    • func ParseJWTToken(tokenStr string, salt []byte) (*CustomJWTClaims, error) 解析JWT-Token字符串
    • func RefreshJWTToken(tokenStr string, salt []byte, survivalTime time.Duration) (string, error) 刷新JWT-Token字符串;
  • u_logger

    • type Level int 日志级别类型
    • type XLogger struct 日志记录器结构体, 继承了标准库的log.Logger
    • func (obj *XLogger) SetLevel(level Level) 设置日志级别
    • func (obj *XLogger) Level() Level 获取日志级别
    • func (obj *XLogger) Debug(msg ...interface{}) 输出Debug级别的日志
    • func (obj *XLogger) Info(msg ...interface{}) 输出Info级别的日志
    • func (obj *XLogger) Warn(msg ...interface{}) 输出Warn级别的日志
    • func (obj *XLogger) Error(msg ...interface{}) 输出Error级别的日志
    • func GetLogger() *XLogger 获取日志记录器对象,单例模式,默认格式与输出
  • u_rotate_file

    • type RotateFileWriter struct 循环文件写入器, 可以帮助我们自己实现循环文件日志
    • func (obj *RotateFileWriter) Write(p []byte) (n int, err error) 往文件写入数据
    • func NewRotateFileWriter(fileName, dirPath string, maxCount int, maxSize int64) *RotateFileWriter 创建新的循环文件写入对象;
  • u_string

    • func BytesMD5Hash(data []byte) string 获取字节数组的MD5签名
    • func StringMD5Hash(data string) string 获取字符串的MD5签名
    • func MultiStringMD5Hash(data ...string) string 获取多个字符串的MD5签名
    • func StringContainsHan(data string) bool 检查字符串是否包含了中文字符
    • func StringContainsSpace(data string) 检查字符串是否包含了空白字符
    • func SafeSliceString(data string, start, end int) (string, error) 安全的字符串切片
  • u_time

    • BJS 北京时间时区
    • func NowTimestamp() int64 当前时间戳
    • func Timestamp2Datetime(timestamp int64, tz *time.Location) time.Time 时间戳转时间对象
    • func Timestamp2DatetimeStr(timestamp int64, tz *time.Location) string 时间戳转时间字符串
    • func BJSNowDatetimeStr() string 当前北京时间字符串
    • func UTCNowDatetimeStr() string 当前UTC时间字符串
    • func BJSTodayDateStr() string 当前北京时间日期字符串
    • func UTCTodayDateStr() string 当前UTC时间日期字符串
    • func Time2BJS(value time.Time) time.Time 时间对象转换到北京时区;

# Functions

No description provided by the author
No description provided by the author
Get the MD5 hash value of bytes.
生成JWT TOKEN: claims 载体数据, salt加密盐值.
No description provided by the author
No description provided by the author
获取目录下是所有文件的绝对路径(不含文件夹, 并且可以通过suffix过滤, 当suffix为空字符串或者"*"时表示配匹所有文件尾缀).
No description provided by the author
Get the MD5 hash value of multi string.
循环文件写入器: fileName基本文件名, dirPath文件夹路径, maxCount最大文件数量, maxSize最大文件体积.
No description provided by the author
解析JWT TOKEN: tokenStr TOKEN字符串, salt加密盐值.
判断文件或者文件夹路径是否存在.
读取csv文件(PS: 去除了空行).
刷新JWT TOKEN tokenStr TOKEN字符串, salt加密盐值, survivalTime存活时间.
No description provided by the author
安全的切割字符串: data原字符串, start切片起点, end切片终点+1 Direct cutting of string may cause character scrambling, because some character could be 3 or 4 byte.
检查字符串是否包含中文字符.
检查字符串是否包含空白字符.
Get the MD5 hash value of string.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
按行读取文件内容, 并判断是否为UTF8编码.

# Constants

Excel单个sheet最多只能有1048576行,超出的行数据将保存到复制了名称的sheet.

# Variables

Set time zone at UTC/GMT+08:00, China Standard Time UTC+8:00.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Error notes.
Error notes.
Error notes.
Error notes.
No description provided by the author

# Structs

自定义载体, CustomData用于保存自定义的数据; jwt.StandardClaims用于存储载体附属信息, 特别是过期时间.
No description provided by the author
Custom rotate file writer.
No description provided by the author

# Type aliases

No description provided by the author