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