package config import ( "log" "os" "github.com/joho/godotenv" ) type Config struct { ServerPort string DBDriver string DBPath string HMACSecret string } func Load() Config { if err := godotenv.Load(); err != nil { log.Println("ERRO: .env not found.") } cfg := Config{ ServerPort: os.Getenv("SERVER_PORT"), DBDriver: os.Getenv("DB_DRIVER"), DBPath: os.Getenv("DB_PATH"), HMACSecret: os.Getenv("HMAC_SECRET"), } if cfg.ServerPort == "" { log.Fatal("ERRO: SERVER_PORT not found.") } if cfg.DBDriver == "" { log.Fatal("ERRO: DB_DRIVER not found.") } if cfg.DBPath == "" { log.Fatal("ERRO: DB_PATH not found.") } if cfg.HMACSecret == "" { log.Fatal("ERRO: HMAC_SECRET not found.") } return cfg }