func (c *XormController) doTransaction(session *xorm.Session, handler SessionHandlerFunc) error { err := session.Begin() if err != nil { return err } if err = handler(session); err == nil { session.Commit() } else { session.Rollback() } return err }