DbMapTransactionSqlExecutor
SqlExecutor
DbMapTransactionTransaction

然后我得到一条消息,如

r.Gorp.Get undefined (type *gorp.SqlExecutor has no field or method Get)

当我尝试使用我的代码 . 我该如何调用这些方法?

代码示例如下 .

package repositories

import (
    "github.com/coopernurse/gorp"
)


type Repository struct {
    Gorp *gorp.SqlExecutor // <<<< Need pointer so I can rollback
}

func (r *Repository) GetById(i interface{}, key interface{}) interface{} {
    obj, err := r.Gorp.Get(i, key)
    if err != nil {
        panic(err)
    }
    return obj
}