refactor: 彻底移除 .env 依赖,配置统一由 config.yaml + 环境变量驱动

This commit is contained in:
hhs
2026-06-14 14:54:55 +08:00
parent d32112e074
commit 4ef1e9f08b
5 changed files with 0 additions and 28 deletions

View File

@@ -5,7 +5,6 @@ import (
"os"
"strings"
"github.com/joho/godotenv"
"github.com/spf13/viper"
)
@@ -161,12 +160,6 @@ func Load() (*Config, error) {
_ = v.MergeInConfig()
}
// 加载 .env 文件(不覆盖已有环境变量)
// 按优先级尝试:当前目录、上级目录(兼容从 backend/ 或项目根目录启动)
_ = godotenv.Load()
_ = godotenv.Load("../.env")
_ = godotenv.Load("../../.env") // 兼容从 backend/cmd/server/ 启动
// 环境变量覆盖
v.SetEnvPrefix("CAMTALK")
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))