Files
sshchat/utils/config.go
2025-10-14 21:21:12 +09:00

35 lines
653 B
Go

package utils
import (
"os"
"strings"
"github.com/joho/godotenv"
)
type Config struct {
Port string
Geoip string
CountryBlacklist []string
PgDsn string
RootPath string
}
func GetConfig() *Config {
_ = godotenv.Load()
port := os.Getenv("PORT")
geoipDbfile := os.Getenv("GEOIP_DB")
countryBlacklist := os.Getenv("COUNTRY_BLACKLIST")
pgDsn := os.Getenv("DB_DSN")
rootPath := os.Getenv("ROOT_PATH")
return &Config{
Port: port,
Geoip: geoipDbfile,
CountryBlacklist: strings.Split(countryBlacklist, ","),
PgDsn: pgDsn,
RootPath: rootPath,
}
}