Files
go-common/README.md

57 lines
1.7 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# GoCommon - Go 通用工具类库
供其他 Go 项目引用的通用工具集合。业务项目对接请直接阅读:
**[业务项目对接操作手册INTEGRATION.md](./INTEGRATION.md)**
## 模块路径
```
git.toowon.com/jimmy/go-common
```
## 安装
```bash
go env -w GOPRIVATE=git.toowon.com
go get git.toowon.com/jimmy/go-common@v2.0.0
```
## 设计概要
- **Factory**:入口,启动时初始化一次,按需 getter 获取模块对象DB、Redis、Logger 等)
- **各模块包**:能力在对象方法上(`log.Info()``store.Upload()`
- **http 包**:统一 HTTP 出参Response / PageData / Handler
- **migration**:独立 CLI 或 Factory 执行 SQL 迁移
- **tools**:无状态工具函数,直接 import
## 功能模块
| 模块 | 包路径 | 说明 |
|------|--------|------|
| 配置 | `config` | JSON 配置加载 |
| 工厂 | `factory` | 统一入口与 lazy getter |
| HTTP | `http` | 请求解析、统一响应 |
| 中间件 | `middleware` | CORS、日志、Recovery、限流、语种、时区 |
| 工具 | `tools` | 时间、加密、金额、类型转换 |
| 日志 | `logger` | 异步日志 |
| 存储 | `storage` | Local / OSS / MinIO |
| 邮件 / 短信 | `email` / `sms` | SMTP、阿里云短信 |
| Excel | `excel` | 数据导出 |
| 国际化 | `i18n` | 多语言消息 |
| 迁移 | `migration` | SQL 版本管理 |
## 文档
| 文档 | 说明 |
|------|------|
| [INTEGRATION.md](./INTEGRATION.md) | 业务项目对接操作手册 |
| [VERSION.md](./VERSION.md) | 版本管理与发布 |
| [templates/](./templates/) | migrate 等脚手架模板 |
| [config/example.json](./config/example.json) | 配置文件示例 |
| [examples/](./examples/) | 代码示例 |
## 许可证
MIT License