Files
sshchat/utils/config.go
2025-10-16 19:50:41 +09:00

38 lines
744 B
Go

package utils
import (
"os"
"strings"
"github.com/joho/godotenv"
)
type Config struct {
Port string
Geoip string
CountryBlacklist []string
PgDsn string
RootPath string
LokiHost 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")
lokiHost := os.Getenv("LOKI_HOST")
return &Config{
Port: port,
Geoip: geoipDbfile,
CountryBlacklist: strings.Split(countryBlacklist, ","),
PgDsn: pgDsn,
RootPath: rootPath,
LokiHost: lokiHost,
}
}