From 72ee39a4c7ee9c8f286846f65ddcbd530340df91 Mon Sep 17 00:00:00 2001 From: Abdellah El Morabit Date: Sat, 18 Oct 2025 17:17:05 +0200 Subject: [PATCH] [refactor] implemented receiver, added package comment --- internal/config/config.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index 4b028b0..abb945a 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -1,3 +1,4 @@ +// Package config loads env fils into a Login struct which gets passed to the rest of the application package config import ( @@ -10,7 +11,7 @@ import ( type Login struct { User string Pass string - Ip string + IP string Port string Name string } @@ -35,17 +36,16 @@ func CreateEnvFile() error { return nil } -func LoadCredentials() Login { +func (L Login) LoadCredentials() Login { err := godotenv.Load(".env") if err != nil { log.Fatal("Error loading .env file") } + L.User = os.Getenv("DATABASE_USER") + L.Pass = os.Getenv("DATABASE_PASSWORD") + L.IP = os.Getenv("DATABASE_IP") + L.Port = os.Getenv("DATABASE_PORT") + L.Name = os.Getenv("DATABASE_NAME") - return Login{ - User: os.Getenv("DATABASE_USER"), - Pass: os.Getenv("DATABASE_PASSWORD"), - Ip: os.Getenv("DATABASE_IP"), - Port: os.Getenv("DATABASE_PORT"), - Name: os.Getenv("DATABASE_NAME"), - } + return L }