From 540eef981f5a493effe526fd085f62064378b613 Mon Sep 17 00:00:00 2001 From: stuzer05 Date: Tue, 8 Oct 2024 16:04:54 +0300 Subject: [PATCH] Loan .env from bin path --- main.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index c7fba18..7122272 100644 --- a/main.go +++ b/main.go @@ -12,15 +12,20 @@ import ( "log" "net/http" "os" + "path/filepath" "stuzer.link/monobank-firefly3-bot/app" ) func main() { - // load .env - err := godotenv.Load(".env") + // Get executable directory + exePath, err := os.Executable() if err != nil { - log.Fatalf("error loading .env file") + log.Fatal("Error getting executable path:", err) } + exeDir := filepath.Dir(exePath) + + // load .env + godotenv.Load(filepath.Join(exeDir, ".env")) // init app app.Init()