package conf import ( "flag" "hilo/common/conf" "hilo/common/env" "hilo/common/logz" "hilo/common/mysql" "hilo/common/redis" ) var ( confPath string Conf = &Config{} ) func init() { flag.StringVar(&confPath, "conf", "config/config.yaml", "指定配置文件 eg: -conf config.yaml") } type Config struct { Server *Server Data *Data Log *logz.Config Consul *Consul Jaeger *Jaeger } type Consul struct { Addr string } type Jaeger struct { Url string } type Data struct { Mysql *mysql.Config Redis *redis.Config } type Server struct { Name string Mode string Version string Grpc struct { Addr string Timeout int } Http struct { Addr string Timeout int } } func LoadConfig() { conf.LoadFromYaml(confPath, &Conf) } func GetMode() string { return Conf.Server.Mode } func AppIsRelease() bool { return GetMode() == env.RELEASE } func AppIsLocal() bool { return GetMode() == env.LOCAL }