From be0f9a30d22a426cb6815c420ed44aa7da661818 Mon Sep 17 00:00:00 2001 From: Fufu Date: Thu, 11 Jul 2024 11:21:44 +0800 Subject: [PATCH] feat: use environment variables to customize BinName, AppName, and DebName --- config/default.go | 8 ++++++++ config/env.go | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/config/default.go b/config/default.go index 213bf08..eb48600 100644 --- a/config/default.go +++ b/config/default.go @@ -16,7 +16,15 @@ var ( BinName = "ffapp" AppName = "FF.App" + + // DebName !!! 这个变量决定自升级时安装命令, 以及日志中显示的包名称 + // 可以在应用程序 func init() { DebName = "your-app" ... } DebName = "ff-app" + + // BinNameEnvName 上面 3 个变量可以在环境变量中设置(优先使用): LOCAL_DEB_NAME=your-web-app + BinNameEnvName = "LOCAL_BIN_NAME" + AppNameEnvName = "LOCAL_APP_NAME" + DebNameEnvName = "LOCAL_DEB_NAME" ) var ( diff --git a/config/env.go b/config/env.go index dc67e23..bbbc92a 100644 --- a/config/env.go +++ b/config/env.go @@ -48,4 +48,17 @@ func loadEnvConfig() { _ = os.Setenv(BaseSecretSaltEnvName, "") BaseSecretSalt = s } + + if s := os.Getenv(BinNameEnvName); s != "" { + _ = os.Setenv(BinNameEnvName, "") + BinName = s + } + if s := os.Getenv(AppNameEnvName); s != "" { + _ = os.Setenv(AppNameEnvName, "") + AppName = s + } + if s := os.Getenv(DebNameEnvName); s != "" { + _ = os.Setenv(DebNameEnvName, "") + DebName = s + } }