apex-toolbox

module
v0.19.4 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: Apache-2.0

README

🚀 Go-ToolbOX

高性能 Go 工具库 - 让开发更简单

为 Go 开发者精心打造的全能工具库,覆盖日常开发 90% 的使用场景


稳定版本 许可协议 下载次数 最新版本 提交记录

代码覆盖率 Go 报告卡 Go 版本 文档


API 文档


✨ 特性亮点

  • 🚀 零依赖设计 - 纯 Go 标准库实现,轻量级
  • 🔧 开箱即用 - 简洁 API 设计,学习成本极低
  • ⚡ 高性能优化 - 针对性能瓶颈深度优化
  • 🛡️ 类型安全 - 完整的泛型支持和类型检查
  • 🧪 测试覆盖 - 90%+ 测试覆盖率,生产环境稳定
  • 📦 模块化 - 按需引入,避免代码膨胀

🏗️ 架构概览

graph TB
    A[Go-ToolbOX] --> B[数据处理]
    A --> C[网络工具]
    A --> D[系统工具]
    A --> E[算法工具]
    A --> F[高可用]
    A --> G[并发工具]
    
    B --> B1[类型转换 convert]
    B --> B2[JSON 处理 json]
    B --> B3[字符串工具 stringx]
    B --> B4[数据脱敏 desensitize]
    
    C --> C1[HTTP 扩展 httpx]
    C --> C2[网络工具 netx]
    C --> C3[位置服务 location]
    
    D --> D1[操作系统 osx]
    D --> D2[时间处理 moment]
    D --> D3[文件压缩 zipx]
    
    E --> E1[数学扩展 mathx]
    E --> E2[加密签名 sign]
    E --> E3[校验算法 crc]
    
    F --> F1[熔断器 breaker]
    
    G --> G1[并发原语 syncx]

🧰 核心模块

📊 数据处理类
模块 功能描述 使用场景
🔄 convert 强类型转换,支持泛型 API 参数转换、配置解析
🎭 desensitize 数据脱敏,保护隐私 日志输出、数据展示
📄 json 高性能 JSON 处理 API 开发、配置管理
🧵 stringx 字符串增强工具 文本处理、模板渲染
📦 serializer 高性能序列化器,支持压缩 队列消息、缓存存储、网络传输
🌐 网络工具类
模块 功能描述 使用场景
🌍 httpx HTTP 客户端增强 API 调用、爬虫开发
🔗 netx 网络工具集 网络检测、连接管理
📍 location IP 地理位置 用户分析、地域限制
📊 metadata HTTP 请求元数据提取 请求分析、日志记录、安全审计
🔍 useragent User-Agent 解析器 设备识别、浏览器检测、爬虫识别
🔧 系统工具类
模块 功能描述 使用场景
🖥️ osx 操作系统接口 系统信息、环境检测
⏰ moment 时间处理增强 日志记录、任务调度
📦 zipx 压缩解压工具 文件处理、数据传输
🧮 算法工具类
模块 功能描述 使用场景
🔢 mathx 数学计算增强、三元运算符 数据分析、算法实现、条件判断
🔐 sign 加密签名工具 安全认证、数据完整性
✅ validator 数据验证器 表单验证、参数检查
🔀 并发工具类
模块 功能描述 使用场景
🔀 syncx 并发原语:ShardedMap、Delayer、Task、原子类型 高并发读写、延迟任务、任务编排
⚙️ 基础设施类
模块 功能描述 使用场景
🛡 breaker 熔断器,服务高可用保护 微服务治理、故障隔离
🔁 retry 智能重试机制 网络请求、服务调用
⏱️ cron Cron 表达式解析器,支持 Quartz 任务调度、定时任务、作业管理
🎲 random 随机数生成 测试数据、算法实现
🆔 uuid UUID 生成器 唯一标识、分布式 ID
⚡ idgen 高性能 ID 生成器 TraceID、分布式 ID、链路追踪
🚦 queue 队列数据结构 任务处理、消息队列

🚀 快速开始

环境要求
  • Go 1.20+
安装
go get -u github.com/HitGameAI/apex-toolbox
基础用法
package main

import (
    "fmt"
    "github.com/HitGameAI/apex-toolbox/pkg/convert"
    "github.com/HitGameAI/apex-toolbox/pkg/stringx"
    "github.com/HitGameAI/apex-toolbox/pkg/moment"
)

func main() {
    // 🔄 类型转换
    num := convert.MustInt("123")        // string -> int
    str := convert.MustString(123)       // int -> string
    
    // 🧵 字符串处理
    result := stringx.New("hello world").
        ToTitle().                       // Hello World
        Replace("World", "Go").          // Hello Go
        String()
    
    // ⏰ 时间处理
    now := moment.Now()
    formatted := now.Format("2006-01-02 15:04:05")
    
    fmt.Printf("转换结果: %d, %s\n", num, str)
    fmt.Printf("字符串: %s\n", result)
    fmt.Printf("时间: %s\n", formatted)
}
高级用法示例
🎭 数据脱敏
import "github.com/HitGameAI/apex-toolbox/pkg/desensitize"

// 手机号脱敏
phone := desensitize.Phone("13812345678")  // 138****5678

// 邮箱脱敏
email := desensitize.Email("test@example.com")  // t***@example.com

// 身份证脱敏
idcard := desensitize.IDCard("110101199001011234")  // 110101****1234
🛡 熔断器(Breaker)
import "github.com/HitGameAI/apex-toolbox/pkg/breaker"

// 创建熔断器
cb := breaker.NewCircuitBreaker(breaker.Config{
    FailureThreshold: 3,
    SuccessThreshold: 2,
    Timeout: time.Second * 5,
})

// 使用熔断器保护业务调用
err := cb.Do(func() error {
    // 你的业务逻辑
    return nil
})
if err != nil {
    // 熔断或业务错误
}
🔁 智能重试
import "github.com/HitGameAI/apex-toolbox/pkg/retry"

err := retry.NewRetry().
    SetAttemptCount(3).
    SetInterval(time.Second).
    SetBackoffMultiplier(2).
    SetJitter(true).
    Do(func() error {
        return callRemoteAPI()
    })
🔢 数学计算与三元运算
import "github.com/HitGameAI/apex-toolbox/pkg/mathx"

// 统计计算
data := []float64{1, 2, 3, 4, 5}
avg := mathx.Mean(data)             // 平均值
max := mathx.Max(data...)           // 最大值(变参)
min := mathx.Min(data...)           // 最小值(变参)
pct := mathx.FormatPercentage(80, 100, 2)  // 百分比格式化 "80.00%"

// 三元运算符
status := mathx.IF(score >= 60, "及格", "不及格")
name := mathx.IfNotEmpty(user.Name, "匿名用户")
value := mathx.IfSafeIndex(slice, index, "默认值")

// 链式条件判断
result := mathx.WhenValue(age >= 18).
    ThenReturn("成年人").
    ElseReturn("未成年人").
    Get()

// 小数位格式化(使用 strconv.FormatFloat 零分配优化)
s := mathx.Decimals(12345, 2)       // "123.45"
🔀 并发原语(syncx)
import "github.com/HitGameAI/apex-toolbox/pkg/syncx"

// 高并发分片映射表(替代 sync.Map,写性能更好)
m := syncx.NewShardedMap[string, int](64) // 64 个分片
m.Store("foo", 1)
m.StoreBatch(map[string]int{"a": 1, "b": 2, "c": 3}) // 批量写入减少锁次数
v, ok := m.Load("foo")     // 读取
m.CompareAndSwap("foo", 1, 100) // 原子 CAS

// 泛型原子值
av := syncx.NewAtomicValue("hello")
av.Store("world")
old := av.Swap("again")     // 原子交换并返回旧值

// 延迟任务执行器(详见 pkg/syncx/DELAY_README.md)
delayer := syncx.NewDelayer[string]().
    WithDelay(100 * time.Millisecond).
    WithTimes(5).
    WithTaskFunc(func(ctx *syncx.ExecutionContext) (string, error) {
        return fmt.Sprintf("task-%d", ctx.Index), nil
    })
_ = delayer.Execute()
delayer.WaitForCompletion()
⚡ 高性能 ID 生成器
import "github.com/HitGameAI/apex-toolbox/pkg/idgen"

// 创建生成器(5种算法可选)
gen := idgen.NewIDGenerator("uuid")  // uuid, nanoid, snowflake, ulid, default

// 生成各类 ID
traceID := gen.GenerateTraceID()           // 分布式追踪 ID
spanID := gen.GenerateSpanID()             // 跨度 ID
requestID := gen.GenerateRequestID()       // 请求 ID
correlationID := gen.GenerateCorrelationID() // 关联 ID

// 直接创建特定生成器
uuidGen := idgen.NewUUIDGenerator()        // UUID v4
nanoGen := idgen.NewNanoIDGenerator()      // NanoID (21字符)
snowflakeGen := idgen.NewSnowflakeGenerator(1, 1)  // Snowflake (分布式)
ulidGen := idgen.NewULIDGenerator()        // ULID (时间排序)
defaultGen := idgen.NewDefaultIDGenerator() // Default Hex

// 特点:零分配优化、并发安全、多种算法
⏱️ Cron 表达式解析器
import "github.com/HitGameAI/apex-toolbox/pkg/cron"

// 解析标准 Cron 表达式(5 字段)
schedule, _ := cron.ParseCronStandard("0 9 * * MON-FRI")

// 解析 Quartz Cron 表达式(6 字段,包含秒)
schedule, _ := cron.ParseCronWithSeconds("*/5 * * * * ?")

// 获取下次执行时间
next := schedule.Next(time.Now())

// 支持 Quartz 特殊字符
cron.ParseCronWithSeconds("0 15 10 ? * 6L")      // 每月最后一个星期五
cron.ParseCronWithSeconds("0 15 10 ? * 6#3")     // 每月第三个星期五
cron.ParseCronWithSeconds("0 0 12 15W * ?")      // 每月 15 号最近的工作日
cron.ParseCronWithSeconds("0 0 12 LW * ?")       // 每月最后一个工作日

// 使用预定义描述符
cron.ParseCronStandard("@daily")          // 每天午夜
cron.ParseCronStandard("@workdays_9am")   // 工作日早 9 点
cron.ParseCronStandard("@every 5m")       // 每 5 分钟

// 特点:支持标准 Cron 和 Quartz、高性能位运算、时区支持

📈 性能基准

在现代硬件环境下的性能表现:

BenchmarkConvert-8           1000000    1.2 ns/op    0 B/op
BenchmarkStringx-8            500000    2.4 ns/op    0 B/op  
BenchmarkMathx-8             2000000    0.8 ns/op    0 B/op
BenchmarkValidator-8          300000    4.1 ns/op    0 B/op

查看测试覆盖率

go test -coverprofile coverage.out
go tool cover -func coverage.out
go test -v 2>&1 | Select-String -Pattern "FAIL"

🤝 社区与支持

贡献指南

我们欢迎所有形式的贡献!请查看 贡献指南

问题反馈
社区支持

📄 许可协议

本项目采用 MIT License 许可协议

🙏 致谢

感谢所有 贡献者 的辛勤付出!


如果这个项目对你有帮助,请给个 ⭐ Star 支持一下!

Made with ❤️ by kamalyes

Directories

Path Synopsis
pkg
argus
Package validator 提供零依赖 struct tag 校验和服务网关常用校验能力
Package validator 提供零依赖 struct tag 校验和服务网关常用校验能力
argus/rule
Package rule 提供 Argus 的标签规则、跨字段规则和时间表达式能力
Package rule 提供 Argus 的标签规则、跨字段规则和时间表达式能力
argus/schema
Package schema 提供轻量 JSON Schema 子集校验能力
Package schema 提供轻量 JSON Schema 子集校验能力
argus/validate
Package validate 承载从 go-toolbox/pkg/validator 迁移而来的通用校验能力
Package validate 承载从 go-toolbox/pkg/validator 迁移而来的通用校验能力
cachex
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-19 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2026-10-27 09:53:20 * @FilePath: \go-toolbox\cachex\\advanced_cache.go * @Description: 高级缓存包装器,支持压缩和泛型,集成队列、热key和分布式锁功能 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-19 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2026-10-27 09:53:20 * @FilePath: \go-toolbox\cachex\\advanced_cache.go * @Description: 高级缓存包装器,支持压缩和泛型,集成队列、热key和分布式锁功能 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
cachex/examples command
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-19 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-19 20:53:00 * @FilePath: \go-toolbox\cachex\\examples\advanced_usage.go * @Description: go-cachex 高级功能使用示例 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-19 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-19 20:53:00 * @FilePath: \go-toolbox\cachex\\examples\advanced_usage.go * @Description: go-cachex 高级功能使用示例 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
cachex/examples/ctxcache command
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-09 21:12:18 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-09 21:45:21 * @FilePath: \go-toolbox\cachex\\examples\ctxcache\advanced.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-09 21:12:18 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-09 21:45:21 * @FilePath: \go-toolbox\cachex\\examples\ctxcache\advanced.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
cachex/examples/expiring command
* @Description: Expiring Cache 高级使用示例
* @Description: Expiring Cache 高级使用示例
cachex/examples/lru_optimized command
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-09 22:45:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-09 22:45:00 * @FilePath: \go-toolbox\cachex\\examples\lru_optimized\basic.go * @Description: LRU优化版本客户端基础使用示例 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-09 22:45:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-09 22:45:00 * @FilePath: \go-toolbox\cachex\\examples\lru_optimized\basic.go * @Description: LRU优化版本客户端基础使用示例 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
cachex/examples/sharded command
* @Description: Sharded Cache 高级使用示例
* @Description: Sharded Cache 高级使用示例
cachex/examples/twolevel command
* @Description: TwoLevel Cache 高级使用示例
* @Description: TwoLevel Cache 高级使用示例
contextx
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2026-01-05 09:55:06 * @FilePath: \go-toolbox\pkg\contextx\core.go * @Description: Context 核心定义和构造函数 * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2026-01-05 09:55:06 * @FilePath: \go-toolbox\pkg\contextx\core.go * @Description: Context 核心定义和构造函数 * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
convert
* @Author: kamalyes 501893067@qq.com * @Date: 2024-11-09 01:15:55 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-11-09 01:05:55 * @FilePath: \go-toolbox\pkg\convert\bytes.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2024-11-09 01:15:55 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-11-09 01:05:55 * @FilePath: \go-toolbox\pkg\convert\bytes.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
crc
* @Author: kamalyes 501893067@qq.com * @Date: 2025-06-09 17:15:16 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-06-11 10:29:15 * @FilePath: \go-toolbox\pkg\crc\config.go * @Description: CRC算法配置库 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2025-06-09 17:15:16 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-06-11 10:29:15 * @FilePath: \go-toolbox\pkg\crc\config.go * @Description: CRC算法配置库 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
cron
* @Author: kamalyes 501893067@qq.com * @Date: 2025-12-24 19:30:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-12-25 11:59:31 * @FilePath: \go-toolbox\pkg\cron\expression.go * @Description: Cron 表达式字段解析器 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2025-12-24 19:30:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-12-25 11:59:31 * @FilePath: \go-toolbox\pkg\cron\expression.go * @Description: Cron 表达式字段解析器 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
desensitize
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-12-23 11:52:30 * @FilePath: \go-toolbox\pkg\desensitize\constants.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-12-23 11:52:30 * @FilePath: \go-toolbox\pkg\desensitize\constants.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
errorx
* @Author: kamalyes 501893067@qq.com * @Date: 2024-11-10 21:51:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-02-15 09:19:15 * @FilePath: \go-toolbox\pkg\errorx\base.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2024-11-10 21:51:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-02-15 09:19:15 * @FilePath: \go-toolbox\pkg\errorx\base.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
httpx
* @Author: kamalyes 501893067@qq.com * @Date: 2024-11-28 18:55:55 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-08-20 16:33:01 * @FilePath: \go-toolbox\pkg\httpx\client.go * @Description: HTTP 客户端实现 * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2024-11-28 18:55:55 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-08-20 16:33:01 * @FilePath: \go-toolbox\pkg\httpx\client.go * @Description: HTTP 客户端实现 * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
i18n/yamlloader
Package yamlloader 提供从 YAML 文件或字符串加载翻译消息的加载器
Package yamlloader 提供从 YAML 文件或字符串加载翻译消息的加载器
imgix
* @Author: kamalyes 501893067@qq.com * @Date: 2024-12-09 12:15:51 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-05-28 17:15:25 * @FilePath: \go-toolbox\pkg\imgix\base.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2024-12-09 12:15:51 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-05-28 17:15:25 * @FilePath: \go-toolbox\pkg\imgix\base.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
json
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-12-18 19:09:16 * @FilePath: \go-toolbox\pkg\json\base.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-12-18 19:09:16 * @FilePath: \go-toolbox\pkg\json\base.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
logger
* @Author: kamalyes 501893067@qq.com * @Date: 2025-12-19 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-12-19 22:59:30 * @FilePath: \go-toolbox\pkg\logger\console.go * @Description: JavaScript console 风格的日志分组和表格功能 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2025-12-19 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-12-19 22:59:30 * @FilePath: \go-toolbox\pkg\logger\console.go * @Description: JavaScript console 风格的日志分组和表格功能 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
mathx
* @Author: kamalyes 501893067@qq.com * @Date: 2024-11-09 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-06-09 15:30:22 * @FilePath: \go-toolbox\pkg\mathx\bit.go * @Description: 位操作相关工具函数集,包含64位和大整数位掩码的生成与解析 * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2024-11-09 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-06-09 15:30:22 * @FilePath: \go-toolbox\pkg\mathx\bit.go * @Description: 位操作相关工具函数集,包含64位和大整数位掩码的生成与解析 * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
metadata
* @Author: kamalyes 501893067@qq.com * @Date: 2025-12-20 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-12-20 15:55:00 * @FilePath: \go-toolbox\pkg\metadata\accessor.go * @Description: 元数据访问器 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2025-12-20 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-12-20 15:55:00 * @FilePath: \go-toolbox\pkg\metadata\accessor.go * @Description: 元数据访问器 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
moment
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-12-03 15:41:12 * @FilePath: \go-toolbox\pkg\moment\base.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-12-03 15:41:12 * @FilePath: \go-toolbox\pkg\moment\base.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
natsx
* @Author: kamalyes 501893067@qq.com * @Date: 2026-04-23 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2026-04-23 00:00:00 * @FilePath: \go-toolbox\pkg\natsx\client.go * @Description: go-toolbox/pkg/natsx 客户端核心结构体 * * 纯易用性封装,不管理连接生命周期,只接受 *nats.Conn * 连接由调用方(如 go-rpc-gateway)负责创建和关闭 * * Copyright (c) 2026 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2026-04-23 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2026-04-23 00:00:00 * @FilePath: \go-toolbox\pkg\natsx\client.go * @Description: go-toolbox/pkg/natsx 客户端核心结构体 * * 纯易用性封装,不管理连接生命周期,只接受 *nats.Conn * 连接由调用方(如 go-rpc-gateway)负责创建和关闭 * * Copyright (c) 2026 by kamalyes, All Rights Reserved.
netx
* @Author: kamalyes 501893067@qq.com * @Date: 2025-09-18 17:22:25 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-21 16:09:51 * @FilePath: \go-toolbox\pkg\netx\ip.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2025-09-18 17:22:25 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-21 16:09:51 * @FilePath: \go-toolbox\pkg\netx\ip.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
ossx
* @Author: kamalyes 501893067@qq.com * @Date: 2026-04-23 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2026-04-23 00:00:00 * @FilePath: \go-toolbox\pkg\ossx\client.go * @Description: go-toolbox/pkg/ossx 对象存储易用性封装客户端 * * 纯易用性封装,不管理连接生命周期 * 连接由调用方(如 go-rpc-gateway)负责创建和关闭 * 通过 Adapter 适配器模式支持 MinIO / AWS S3 / 阿里云 OSS / 腾讯云 COS / Cloudflare R2 Worker * * Copyright (c) 2026 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2026-04-23 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2026-04-23 00:00:00 * @FilePath: \go-toolbox\pkg\ossx\client.go * @Description: go-toolbox/pkg/ossx 对象存储易用性封装客户端 * * 纯易用性封装,不管理连接生命周期 * 连接由调用方(如 go-rpc-gateway)负责创建和关闭 * 通过 Adapter 适配器模式支持 MinIO / AWS S3 / 阿里云 OSS / 腾讯云 COS / Cloudflare R2 Worker * * Copyright (c) 2026 by kamalyes, All Rights Reserved.
ossx/adapter/minio
* @Author: kamalyes 501893067@qq.com * @Date: 2026-04-23 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2026-04-23 00:00:00 * @FilePath: \go-toolbox\pkg\ossx\adapter\minio\minio.go * @Description: MinIO 对象存储适配器 * * 基于 minio-go/v7 实现 ossx.Adapter 接口 * 支持:预签名上传/下载、对象 CRUD、桶存在判断 * * Copyright (c) 2026 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2026-04-23 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2026-04-23 00:00:00 * @FilePath: \go-toolbox\pkg\ossx\adapter\minio\minio.go * @Description: MinIO 对象存储适配器 * * 基于 minio-go/v7 实现 ossx.Adapter 接口 * 支持:预签名上传/下载、对象 CRUD、桶存在判断 * * Copyright (c) 2026 by kamalyes, All Rights Reserved.
ossx/adapter/r2
* @Author: kamalyes 501893067@qq.com * @Date: 2026-04-23 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2026-04-23 00:00:00 * @FilePath: \go-toolbox\pkg\ossx\adapter\r2\r2.go * @Description: Cloudflare R2 Worker 对象存储适配器 * * 通过 Cloudflare Worker 代理访问 R2 存储 * 使用 AES-CBC-PKCS7 加密签名保证安全性 * 仅支持:预签名上传地址、上传对象(其他操作通过 Worker API 扩展) * * Copyright (c) 2026 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2026-04-23 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2026-04-23 00:00:00 * @FilePath: \go-toolbox\pkg\ossx\adapter\r2\r2.go * @Description: Cloudflare R2 Worker 对象存储适配器 * * 通过 Cloudflare Worker 代理访问 R2 存储 * 使用 AES-CBC-PKCS7 加密签名保证安全性 * 仅支持:预签名上传地址、上传对象(其他操作通过 Worker API 扩展) * * Copyright (c) 2026 by kamalyes, All Rights Reserved.
osx
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-12-04 19:31:22 * @FilePath: \go-toolbox\pkg\osx\base.go * @Description: 操作系统相关工具函数 * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-12-04 19:31:22 * @FilePath: \go-toolbox\pkg\osx\base.go * @Description: 操作系统相关工具函数 * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
pbmo
Package pbmo 在 protobuf 生成结构体与领域/GORM 模型之间做字段映射转换
Package pbmo 在 protobuf 生成结构体与领域/GORM 模型之间做字段映射转换
protox
Package protox 收口 go-toolbox 中真正需要 google.golang.org/protobuf 的反射辅助 分出来的目的:pkg/types 被 mathx / convert / syncx 等大量基础包依赖,一旦它引入 protobuf,所有使用者(go-cachex、go-toolbox/pkg/i18n 等)都会被动承担 30+ 个 protobuf 包
Package protox 收口 go-toolbox 中真正需要 google.golang.org/protobuf 的反射辅助 分出来的目的:pkg/types 被 mathx / convert / syncx 等大量基础包依赖,一旦它引入 protobuf,所有使用者(go-cachex、go-toolbox/pkg/i18n 等)都会被动承担 30+ 个 protobuf 包
queue
* @Author: kamalyes 501893067@qq.com * @Date: 2025-01-20 10:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-01-20 10:00:00 * @FilePath: \go-toolbox\pkg\queue\bounded_queue.go * @Description: * BoundedQueue 是一个有界队列实现,支持最小/最大容量限制、自动扩缩容、阻塞/非阻塞操作 * 采用智能增长策略:小容量快速增长(2x),中容量渐进增长(1.5x),大容量固定增量 * 适用于需要流量控制、内存保护的高并发场景 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2025-01-20 10:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-01-20 10:00:00 * @FilePath: \go-toolbox\pkg\queue\bounded_queue.go * @Description: * BoundedQueue 是一个有界队列实现,支持最小/最大容量限制、自动扩缩容、阻塞/非阻塞操作 * 采用智能增长策略:小容量快速增长(2x),中容量渐进增长(1.5x),大容量固定增量 * 适用于需要流量控制、内存保护的高并发场景 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
random
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-08-05 10:50:01 * @FilePath: \go-toolbox\pkg\random\business.go * @Description: 生成业务相关的随机数据 * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-08-05 10:50:01 * @FilePath: \go-toolbox\pkg\random\business.go * @Description: 生成业务相关的随机数据 * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
retry
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58
safe
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-16 22:55:55 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-16 22:55:55 * @FilePath: \go-toolbox\pkg\safe\mathx.go * @Description: 安全的数学工具函数集合,提供各种数学算法的安全实现 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-16 22:55:55 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-16 22:55:55 * @FilePath: \go-toolbox\pkg\safe\mathx.go * @Description: 安全的数学工具函数集合,提供各种数学算法的安全实现 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
serializer
* @Author: kamalyes 501893067@qq.com * @Date: 2025-02-28 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2026-05-13 13:15:15 * @FilePath: \go-toolbox\pkg\serializer\json.go * @Description: JSON解析和转换工具 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2025-02-28 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2026-05-13 13:15:15 * @FilePath: \go-toolbox\pkg\serializer\json.go * @Description: JSON解析和转换工具 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
sign
* @Author: kamalyes 501893067@qq.com * @Date: 2024-10-23 17:37:08 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-10-23 17:58:07 * @FilePath: \go-toolbox\pkg\sign\aes.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2024-10-23 17:37:08 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-10-23 17:58:07 * @FilePath: \go-toolbox\pkg\sign\aes.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
sqlbuilder
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-11 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2026-05-08 15:11:22 * @FilePath: \go-toolbox\pkg\sqlbuilder\types.go * @Description: 类型重导出兼容层 - 保持 sqlbuilder.MapAny 等外部引用不变 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-11 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2026-05-08 15:11:22 * @FilePath: \go-toolbox\pkg\sqlbuilder\types.go * @Description: 类型重导出兼容层 - 保持 sqlbuilder.MapAny 等外部引用不变 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
sqlbuilder/constants
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-30 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-30 00:00:00 * @FilePath: \go-toolbox\pkg\sqlbuilder\constants\database.go * @Description: 数据库类型常量定义 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-30 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-30 00:00:00 * @FilePath: \go-toolbox\pkg\sqlbuilder\constants\database.go * @Description: 数据库类型常量定义 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
sqlbuilder/db
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-11 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-23 13:05:48 * @FilePath: \go-toolbox\pkg\sqlbuilder\db\handler.go * @Description: 数据库处理器 - Handler 接口和 GORM 实现 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-11 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-23 13:05:48 * @FilePath: \go-toolbox\pkg\sqlbuilder\db\handler.go * @Description: 数据库处理器 - Handler 接口和 GORM 实现 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
sqlbuilder/errors
* @Author: kamalyes 501893067@qq.com * @Date: 2025-12-13 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-12-13 10:26:53 * @FilePath: \go-toolbox\pkg\sqlbuilder\errors\checker.go * @Description: 数据库错误检测工具函数 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2025-12-13 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-12-13 10:26:53 * @FilePath: \go-toolbox\pkg\sqlbuilder\errors\checker.go * @Description: 数据库错误检测工具函数 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
sqlbuilder/repository
* @Author: kamalyes 501893067@qq.com * @Date: 2025-07-30 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2026-07-30 13:26:08 * @FilePath: \go-toolbox\pkg\sqlbuilder\repository\async_batch_writer.go * @Description: 通用异步批量写入器,适用于高频写入低频查询的场景(如 ClickHouse 日志表) * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2025-07-30 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2026-07-30 13:26:08 * @FilePath: \go-toolbox\pkg\sqlbuilder\repository\async_batch_writer.go * @Description: 通用异步批量写入器,适用于高频写入低频查询的场景(如 ClickHouse 日志表) * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
sqlbuilder/types
* @Author: kamalyes 501893067@qq.com * @Date: 2026-07-30 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2026-07-30 00:00:00 * @FilePath: \go-toolbox\pkg\sqlbuilder\types\compressed.go * @Description: 数据库压缩存储类型——字段级透明 gzip 压缩,多 DB 方言适配 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2026-07-30 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2026-07-30 00:00:00 * @FilePath: \go-toolbox\pkg\sqlbuilder\types\compressed.go * @Description: 数据库压缩存储类型——字段级透明 gzip 压缩,多 DB 方言适配 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
stringx
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-27 23:55:26 * @FilePath: \go-toolbox\pkg\stringx\base.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-27 23:55:26 * @FilePath: \go-toolbox\pkg\stringx\base.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
syncx
* @Author: kamalyes 501893067@qq.com * @Date: 2025-01-05 15:08:55 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-01-09 15:07:15 * @FilePath: \go-toolbox\pkg\syncx\atomic.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2025-01-05 15:08:55 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-01-09 15:07:15 * @FilePath: \go-toolbox\pkg\syncx\atomic.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
types
* @Author: kamalyes 501893067@qq.com * @Date: 2025-01-23 09:11:20 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-12-24 18:59:29 * @FilePath: \go-toolbox\pkg\types\bound.go * @Description: 边界和范围相关的类型定义 * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2025-01-23 09:11:20 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-12-24 18:59:29 * @FilePath: \go-toolbox\pkg\types\bound.go * @Description: 边界和范围相关的类型定义 * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
units
* @Author: kamalyes 501893067@qq.com * @Date: 2025-06-17 13:15:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-06-17 13:55:17 * @FilePath: \go-toolbox\pkg\units\constants.go * @Description: 单位常量及单位映射定义 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2025-06-17 13:15:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-06-17 13:55:17 * @FilePath: \go-toolbox\pkg\units\constants.go * @Description: 单位常量及单位映射定义 * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
useragent
* @Author: kamalyes 501893067@qq.com * @Date: 2025-04-21 13:58:25 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-04-23 11:25:40 * @FilePath: \go-toolbox\pkg\useragent\consts.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2025-04-21 13:58:25 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-04-23 11:25:40 * @FilePath: \go-toolbox\pkg\useragent\consts.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
zipx
* @Author: kamalyes 501893067@qq.com * @Date: 2024-10-24 11:25:16 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-12-04 18:26:12 * @FilePath: \go-toolbox\pkg\zipx\zlib.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2024-10-24 11:25:16 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-12-04 18:26:12 * @FilePath: \go-toolbox\pkg\zipx\zlib.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.

Jump to

Keyboard shortcuts

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