package cfg import ( "flag" "io/ioutil" "gopkg.in/yaml.v2" mc "applet/app/utils/cache/cache" "applet/app/utils/logx" ) func InitTaskCfg() { path := flag.String("c", "etc/task.yml", "config file") flag.Parse() var ( c []byte err error conf *Config ) if c, err = ioutil.ReadFile(*path); err != nil { panic(err) } if err = yaml.Unmarshal(c, &conf); err != nil { panic(err) } Prd = conf.Prd Debug = conf.Debug DB = &conf.DB IMDB = &conf.ImDB Log = &conf.Log RedisAddr = conf.RedisAddr MQ = &conf.MQ ES = &conf.ES } var MemCache mc.Cache func InitMemCache() { var err error MemCache, err = mc.NewCache("memory", `{"interval":60}`) if err != nil { logx.Fatal(err.Error()) } }