refactor: 彻底移除 .env 依赖,配置统一由 config.yaml + 环境变量驱动
This commit is contained in:
@@ -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(".", "_"))
|
||||
|
||||
Reference in New Issue
Block a user