diff --git a/main.go b/main.go index 2f3c41f..43101ae 100644 --- a/main.go +++ b/main.go @@ -5,12 +5,21 @@ import ( "gitea.stuzer.link/stuzer05/docker-registry-manager/cmd" "gitea.stuzer.link/stuzer05/docker-registry-manager/internal/app" "github.com/joho/godotenv" + "log" "os" + "path/filepath" ) func main() { + // Get executable directory + exePath, err := os.Executable() + if err != nil { + log.Fatal("Error getting executable path:", err) + } + exeDir := filepath.Dir(exePath) + // Load .env file - err := godotenv.Load() + err = godotenv.Load(filepath.Join(exeDir, ".env")) if err != nil { fmt.Println("Error loading .env file:", err) return