package conf import ( "flag" "hilo/common/aws" "hilo/common/conf" "hilo/common/env" "hilo/common/logz" "hilo/common/mysql" "hilo/common/oss" "hilo/common/redis" "hilo/common/tencent" ) 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 Aws *aws.Config Oss *oss.Config TencentYun *tencent.Config Auth *Auth Client *Client } type Auth struct { ImeiTotalLimit int ImeiOauthLimit int AccountIpLimit int AccountIpDurationLimit int Jwt struct { Expire string Secret string Issuer string } } type Consul struct { Addr string } type Jaeger struct { Url string } type Data struct { Mysql *mysql.Config Redis *redis.Config } type Server struct { Name string Version string Mode string Grpc struct { Addr string Timeout int } Http struct { Addr string Timeout int } } type Client struct { Mgr struct { Endpoint string } Country struct { Endpoint string } } 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 }