specify the base directory for loading the .env file

This commit is contained in:
Alfred Kamanda 2025-01-06 14:50:39 +03:00 committed by konstantinmds
parent 2f634d550b
commit a9c7a40ff3

View File

@ -3,15 +3,17 @@ package initializers
import ( import (
"log" "log"
"os" "os"
"path"
"strconv" "strconv"
"github.com/joho/godotenv" "github.com/joho/godotenv"
) )
func LoadEnvVariables() { func LoadEnvVariables(baseDir string) {
err := godotenv.Load() envDir := path.Join(baseDir, ".env")
err := godotenv.Load(envDir)
if err != nil { if err != nil {
log.Fatal("Error loading .env file") log.Fatal("Error loading .env file", err)
} }
} }