package config import ( "os" "strconv" ) type Config struct { Mode string DatabaseUrl string Port int Ip string AuthEnabled bool AuthUsername string AuthPassword string AuthKey string } func LoadConfig() *Config { port, err := strconv.Atoi(os.Getenv("PORT")) if err != nil { panic(err) } config := Config{ Mode: os.Getenv("GIN_MODE"), DatabaseUrl: os.Getenv("DATABASE_URL"), Port: port, Ip: os.Getenv("BIND_IP"), AuthEnabled: os.Getenv("AUTH_ENABLED") != "false", AuthUsername: os.Getenv("AUTH_USERNAME"), AuthPassword: os.Getenv("AUTH_PASSWORD"), AuthKey: os.Getenv("AUTH_KEY"), } // TODO: Crash when any auth* param is empty return &config }