修改包名

This commit is contained in:
2025-11-30 13:43:43 +08:00
parent 23d3840050
commit a655640ab2
38 changed files with 729 additions and 104 deletions

View File

@@ -103,7 +103,7 @@
### 1. 加载配置文件
```go
import "git.toowon.com/jimmy/go-commom/config"
import "git.toowon.com/jimmy/go-common/config"
// 从文件加载配置(支持绝对路径和相对路径)
config, err := config.LoadFromFile("/path/to/config.json")
@@ -167,7 +167,7 @@ addr := config.GetRedisAddr()
corsConfig := config.GetCORS()
// 使用CORS中间件
import "git.toowon.com/jimmy/go-commom/middleware"
import "git.toowon.com/jimmy/go-common/middleware"
chain := middleware.NewChain(
middleware.CORS(corsConfig),
)
@@ -279,6 +279,16 @@ if minioConfig != nil {
| Endpoint | string | 服务端点(可选,默认使用区域端点) | - |
| Timeout | int | 请求超时时间(秒) | 10 |
### LoggerConfig 日志配置
| 字段 | 类型 | 说明 | 默认值 |
|------|------|------|--------|
| Level | string | 日志级别: debug, info, warn, error | info |
| Output | string | 输出方式: stdout, stderr, file, both | stdout |
| FilePath | string | 日志文件路径当output为file或both时必需 | - |
| Prefix | string | 日志前缀 | - |
| DisableTimestamp | bool | 禁用时间戳 | false |
## 完整示例
### 示例1加载配置并使用
@@ -289,8 +299,8 @@ package main
import (
"log"
"git.toowon.com/jimmy/go-commom/config"
"git.toowon.com/jimmy/go-commom/middleware"
"git.toowon.com/jimmy/go-common/config"
"git.toowon.com/jimmy/go-common/middleware"
"gorm.io/driver/mysql"
"gorm.io/gorm"
)
@@ -466,6 +476,12 @@ dsn, err := cfg.GetDatabaseDSN()
**返回:** 短信配置对象可能为nil
### (c *Config) GetLogger() *LoggerConfig
获取日志配置。
**返回:** 日志配置对象可能为nil
## 注意事项
1. **配置文件路径**