func init() { cfg := new(config) in, err := ioutil.ReadFile("config.yaml") if err != nil { log.Fatal(err) } err = goyaml.Unmarshal(in, cfg) if err != nil { log.Fatal(err) } flag.Parse() log.SetOutputLevel(log.Ldebug) if *environment == "development" { opts = &cfg.Development } else { opts = &cfg.Production } fmt.Println("== environment:", *environment, "==") utils.Dump(opts) conf.ACCESS_KEY = opts.AccessKey conf.SECRET_KEY = opts.SecretKey // render html templates from templates directory m.Use(render.Renderer(render.Options{ Layout: "layout", })) InitRouter() }
func (b *Builder) pack(bins []string, rcfile string) (path string, err error) { log.Debug(bins) log.Debug(rcfile) data, err := ioutil.ReadFile(rcfile) if err != nil { log.Debug("use default rc") data, err = ioutil.ReadFile("public/gobuildrc") if err != nil { log.Error(err) } } ass := new(Assembly) err = goyaml.Unmarshal(data, ass) if err != nil { return } dir := filepath.Dir(rcfile) fs, err := ioutil.ReadDir(dir) if err != nil { return } var includes = bins // this may change slice bins for _, f := range fs { var ok = false for _, patten := range ass.Includes { if match(patten, f.Name()) { ok = true break } } if ok { includes = append(includes, filepath.Join(dir, f.Name())) } } return pkgZip(dir, includes) }