package config import ( "gitea.baoapi.com/root/stu_uuos/util" "github.com/micro/go-micro/v2/config" ) var conf *Config type Config struct { Version string ServiceName string Address int SinglePoint bool Domain string DB *Database // postgress -> gy_uums DB2 *Database // postgress -> gy_order DB3 *Database // postgress -> gy_cloud Log *Log LogrusHttp *LogrusHttp ApiAddr *ApiAddress `yaml:"apiAddr"` Redis *Redis Nats *Nats JWT *Jwt Minio *Minio Micro *Micro Gather *Gather Gyys *Gyys Mail *Mail CompanyWxSync *CompanyWxSync } type Gather struct { Domain string Userid string Orgid string } type Gyys struct { Domain string } type Nats struct { Addr string Subject map[string]string } type Jwt struct { SigningKey string } type Micro struct { Registry Registry Service Service } type Registry struct { Name string Addrs string } type Service struct { Cipher string } //CompanyWxSync 运营企业微信同步 type CompanyWxSync struct { Id string //商户id PartyId string //目标部门id } func GetConfig() *Config { return conf } func Init() { if conf != nil { return } f, err := util.FindFile("conf.yaml") if err != nil { panic(err) } util.PrintInfo(f) if err := config.LoadFile(f); err != nil { panic(err) } conf = &Config{} if err := config.Scan(conf); err != nil { panic(err) } util.PrintJSON(conf) go watch(f) } func watch(f string) { w, err := config.Watch(f) if err != nil { util.PrintErr(err) return } v, err := w.Next() if err != nil { util.PrintErr(err) return } if err := v.Scan(conf); err != nil { util.PrintErr(err) } util.PrintInfo("the config file 'conf.yaml' has been changed:") util.PrintJSON(conf) }