mirror of
https://github.com/dalbodeule/sshchat.git
synced 2025-12-07 22:55:44 +09:00
38 lines
744 B
Go
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,
|
|
}
|
|
}
|