添加运行模式配置,优化调试和生产环境的日志输出

This commit is contained in:
2025-05-07 19:03:44 +08:00
parent 0a16f9923c
commit 0e0affb008
5 changed files with 61 additions and 11 deletions

11
pkg/env/env.go vendored
View File

@@ -13,6 +13,7 @@ import (
var (
AppName = "platform"
RunMode = "debug" // debug, production
)
func loadApp() {
@@ -20,6 +21,16 @@ func loadApp() {
if _AppName != "" {
AppName = _AppName
}
_RunMode := os.Getenv("RUN_MODE")
switch _RunMode {
case "debug", "production":
RunMode = _RunMode
case "":
break
default:
panic("环境变量 RUN_MODE 的值只能是 debug 或 production")
}
}
// endregion