package conf import "git.168cad.top/zhengqiuyun/rym-util/util" type Config struct { ServerName string Env string HttpPort int LogLevel string LogColorful bool LogResponseLength int LogShowSql bool Redis RedisConf Elasticsearch EsConf Mysql MysqlConf } func BaseConfig(conf Config) { if util.IsEmpty(&conf.ServerName) { panic("ServerName error") } else { ServerName = conf.ServerName } if util.IsEmpty(&conf.Env) { panic("Env error") } else { Env = conf.Env } if conf.HttpPort < 1024 { panic("HttpPort error") } else { HttpPort = conf.HttpPort } if util.IsEmpty(&conf.LogLevel) { LogLevel = "DEBUG" } else { LogLevel = conf.LogLevel } LogColorful = conf.LogColorful LogResponseLength = conf.LogResponseLength LogShowSql = conf.LogShowSql Es = conf.Elasticsearch Redis = conf.Redis MySql = conf.Mysql } //Base conf var ServerName string var Env string var HttpPort int //log conf var LogLevel = "DEBUG" var LogColorful = true var LogResponseLength int var LogShowSql = true //Redis conf type RedisConf struct { RedisHost string RedisPort int RedisPwd string RedisDb int } var Redis = RedisConf{} //ES conf type EsConf struct { ServerHost string ServerPort int } var Es = EsConf{} //Mysql conf type MysqlConf struct { Host string Port int User string Password string } var MySql = MysqlConf{}