Loan .env from bin path

This commit is contained in:
Illya Marchenko 2024-10-08 16:04:54 +03:00
parent 7c03492676
commit 540eef981f
Signed by: stuzer05
GPG Key ID: A6ABAAA9268F9F4F

11
main.go

@ -12,15 +12,20 @@ import (
"log" "log"
"net/http" "net/http"
"os" "os"
"path/filepath"
"stuzer.link/monobank-firefly3-bot/app" "stuzer.link/monobank-firefly3-bot/app"
) )
func main() { func main() {
// load .env // Get executable directory
err := godotenv.Load(".env") exePath, err := os.Executable()
if err != nil { 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 // init app
app.Init() app.Init()