Files
sshchat/utils/config.go
2025-10-14 20:16:42 +09:00

36 lines
631 B
Go

package utils
import (
"log"
"os"
"strings"
"github.com/joho/godotenv"
)
type Config struct {
Port string
Geoip string
CountryBlacklist []string
PgDsn string
}
func GetConfig() *Config {
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
port := os.Getenv("PORT")
geoipDbfile := os.Getenv("GEOIP_DB")
countryBlacklist := os.Getenv("COUNTRY_BLACKLIST")
pgDsn := os.Getenv("DB_DSN")
return &Config{
Port: port,
Geoip: geoipDbfile,
CountryBlacklist: strings.Split(countryBlacklist, ","),
PgDsn: pgDsn,
}
}