Files
2025-08-28 13:26:16 +02:00

46 lines
774 B
Go

package config
import (
"os"
// this will automatically load your .env file:
_ "github.com/joho/godotenv/autoload"
)
type Config struct {
Logs LogConfig
DB PostgresConfig
Port string
}
type LogConfig struct {
Style string
Level string
}
type PostgresConfig struct {
Username string
Password string
Db string
Host string
Port string
}
var Cfg *Config
func LoadConfig() {
Cfg = &Config{
Port: os.Getenv("PORT"),
Logs: LogConfig{
Style: os.Getenv("LOG_STYLE"),
Level: os.Getenv("LOG_LEVEL"),
},
DB: PostgresConfig{
Username: os.Getenv("POSTGRES_USER"),
Password: os.Getenv("POSTGRES_PWD"),
Db: os.Getenv("POSTGRES_DB"),
Host: os.Getenv("POSTGRES_HOST"),
Port: os.Getenv("POSTGRES_PORT"),
},
}
}