支持通过命令行参数指定配置文件路径,优化配置文件加载逻辑

This commit is contained in:
2026-01-26 23:34:52 +08:00
parent 97df85d4f8
commit e2a99b7888
4 changed files with 32 additions and 6 deletions

View File

@@ -23,12 +23,12 @@ import (
)
// Init 初始化应用各项服务
func Init(webFS embed.FS) *gin.Engine {
func Init(webFS embed.FS, configPath string) *gin.Engine {
// 0. 确保数据目录存在
_ = os.MkdirAll("data/picture", 0755)
// 1. 初始化配置
if err := config.Init(""); err != nil {
if err := config.Init(configPath); err != nil {
log.Fatalf("Failed to initialize config: %v", err)
}
cfg := config.GetConfig()