Ejemplo n.º 1
0
func init() {
	log.Logger.Info("init db engine ...")

	var err error
	{ //创建数据库engine
		Engine, err = xorm.NewEngine("", ":@tcp()/?charset=utf8&parseTime=true")
		util.PanicError(err)

		Engine.ShowSQL = true
		Engine.ShowDebug = true
		Engine.ShowErr = true
		Engine.ShowInfo = true
		Engine.ShowWarn = true

		Engine.SetMaxIdleConns(20)
		Engine.SetMaxOpenConns(30)

		err = Engine.Ping()
		util.PanicError(err)
	}

	log.Logger.Info("db engine inited")
}
Ejemplo n.º 2
0
func (r *rend) JSON(data interface{}) {
	result, err := jsonutils.Marshal(data, true)
	util.PanicError(err)
	r.context.String(http.StatusOK, "%s", result)
}