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
View File

@ -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()