xutils

module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2025 License: MIT

README

goreportcard

Go语言工具库

集成常用的开发工具包


✨ 功能模块概述

  • xauth:JWT签发与解析,简化Token认证流程。
  • xcache:统一缓存接口,支持多种存储后端。
  • xcli:命令行交互、终端UI、进度条、表格渲染等。
  • xconvert:类型转换、颜色转换等常用转换工具。
  • xcrypto:AES、RSA等加解密算法封装,以及MD5,Sha1,Sha256摘要计算。
  • xencoding:Base64、URL、JSON等常用编码解码。
  • xerror:错误码定义、错误处理与调用栈追踪。
  • xfile:文件读写、类型判断等。
  • xfilter:过滤器、变量上下文、条件表达式。
  • xgen:ID生成、雪花算法等。
  • xgit:Git仓库相关操作。
  • xgorm:GORM数据库扩展,集成缓存。
  • xhashring:一致性哈希算法。
  • xhttp:HTTP请求、Header、重试、超时等。
  • ximg:图片处理、EXIF、合成、圆角等。
  • xip:IP、MAC、域名等网络工具。
  • xjson:JSON序列化、反序列化、工具函数。
  • xlodash:集合、切片、Map等常用操作。
  • xpool:协程池、任务池。
  • xregex:正则表达式工具。
  • xstruct:结构体相关工具。
  • xticker:定时器。
  • xtime:时间格式化、定时、超时等。
  • xtype:类型转换。
  • xutil:常用工具函数,如三目运算、字符串处理等。
  • xversion:版本号格式化与比较。

🚀 快速上手

以 xauth JWT 为例:

import "github.com/falcolee/xutils/xauth"

// 生成Token
claims := map[string]interface{}{"uid": 123}
token, err := xauth.GetJWT("your-secret", claims, 3600)

// 解析Token
parsed, err := xauth.ParseJWT("your-secret", token)

以 xfile 文件操作为例:

import "github.com/falcolee/xutils/xfile"

// 读取JSON文件
var data map[string]interface{}
err := xfile.ReadJSON("data.json", &data)

// 写入JSON文件
err = xfile.WriteJSON("data.json", data)

更多模块用法请参考各子目录源码与注释。


📄 License

MIT License

Directories

Path Synopsis
* @Date: 2023-07-20 09:46:36 * @LastEditTime: 2023-07-20 09:46:37 * @Description:
* @Date: 2023-07-20 09:46:36 * @LastEditTime: 2023-07-20 09:46:37 * @Description:
store/memory
* @Date: 2024-06-20 09:48:51 * @LastEditTime: 2024-06-21 09:48:52 * @Description:
* @Date: 2024-06-20 09:48:51 * @LastEditTime: 2024-06-21 09:48:52 * @Description:
store/redis
* @Date: 2023-07-20 09:48:51 * @LastEditTime: 2023-07-20 09:48:52 * @Description:
* @Date: 2023-07-20 09:48:51 * @LastEditTime: 2023-07-20 09:48:52 * @Description:
xcolor/example command
xtable/example command
* @Date: 2023-07-20 09:34:46 * @LastEditTime: 2023-09-07 16:39:33 * @Description:
* @Date: 2023-07-20 09:34:46 * @LastEditTime: 2023-09-07 16:39:33 * @Description:
* @Date: 2023-07-20 10:22:13 * @LastEditTime: 2023-07-20 10:50:26 * @Description:
* @Date: 2023-07-20 10:22:13 * @LastEditTime: 2023-07-20 10:50:26 * @Description:
* @Date: 2023-07-20 10:09:47 * @LastEditTime: 2023-07-20 10:16:49 * @Description:
* @Date: 2023-07-20 10:09:47 * @LastEditTime: 2023-07-20 10:16:49 * @Description:
* @Date: 2023-07-20 09:38:29 * @LastEditTime: 2023-07-20 09:43:16 * @Description:
* @Date: 2023-07-20 09:38:29 * @LastEditTime: 2023-07-20 09:43:16 * @Description:
* @Date: 2023-07-11 13:55:42 * @LastEditTime: 2023-07-12 14:28:40 * @Description:
* @Date: 2023-07-11 13:55:42 * @LastEditTime: 2023-07-12 14:28:40 * @Description:
* @Date: 2023-07-20 10:24:45 * @LastEditTime: 2023-07-20 10:24:57 * @Description:
* @Date: 2023-07-20 10:24:45 * @LastEditTime: 2023-07-20 10:24:57 * @Description:
* @Date: 2023-07-20 09:34:46 * @LastEditTime: 2023-07-20 10:26:35 * @Description:
* @Date: 2023-07-20 09:34:46 * @LastEditTime: 2023-07-20 10:26:35 * @Description:
* @Date: 2023-04-03 13:43:34 * @LastEditTime: 2023-07-20 09:57:32 * @Description:
* @Date: 2023-04-03 13:43:34 * @LastEditTime: 2023-07-20 09:57:32 * @Description:

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL