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 Log = &conf.Log Admin = &conf.Admin RedisAddr = conf.RedisAddr Local = conf.Local AppComm = &conf.AppComm } var MemCache mc.Cache func InitMemCache() { var err error MemCache, err = mc.NewCache("memory", `{"interval":60}`) if err != nil { logx.Fatal(err.Error()) } }