-3
/ Code generated by sqlc. DO NOT EDIT.
package db
import (
    "context"
    "database/sql"
)
type DBTX interface {
    ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
    PrepareContext(context.Context, string) (*sql.Stmt, error)
    QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
    QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}
func New(db DBTX) *Queries {
    return &Queries{db: db}
}
type Queries struct {
    db DBTX
}
func (q *Queries) WithTx(tx *sql.Tx) *Queries {
    return &Queries{
        db: tx, // here the error is being displayed
    }
}

错误

不能使用 tx(*sql.Tx 类型的变量)作为结构文字中的 DBTX 值:方法 ExecContext 的类型错误(具有 func(ctx context.Context,查询字符串,args ...接口{})(数据库/sql.Result , error), want func(context.Context, string, ...interface{}) (database/sql.Result, error)) compilerInvalidIfaceAssign

4

1 回答 1

-1

这是 VS CODE 的错误,我强烈建议使用 GOLAND by jetbrains for golang

于 2021-09-10T06:36:42.210 回答