From 5d7c8ba4a5f3371b16a53b009c6663a66d30b21a Mon Sep 17 00:00:00 2001 From: Albert Wang Date: Sat, 4 Mar 2023 00:55:44 -0800 Subject: [PATCH] Add a nodotenv config to disable autoloading .env files --- main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 52df847..18d70da 100644 --- a/main.go +++ b/main.go @@ -7,7 +7,6 @@ import ( "github.com/appleboy/easyssh-proxy" "github.com/joho/godotenv" - _ "github.com/joho/godotenv/autoload" "github.com/urfave/cli/v2" ) @@ -15,6 +14,13 @@ import ( var Version string func main() { + // Load dotenv unless explicitly ignored + if noAutoEnv, found := os.LookupEnv("PLUGIN_NO_AUTO_ENV"); found { + if noAutoEnv != "true" { + _ = godotenv.Load() + } + } + // Load env-file if it exists first if filename, found := os.LookupEnv("PLUGIN_ENV_FILE"); found { _ = godotenv.Load(filename)