-2
/ 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
    }
}

ERROR

cannot use tx (variable of type *sql.Tx) as DBTX value in struct literal: wrong type for method ExecContext (have func(ctx context.Context, query string, args ...interface{}) (database/sql.Result, error), want func(context.Context, string, ...interface{}) (database/sql.Result, error)) compilerInvalidIfaceAssign

  • 1
    What version of Go are you running? Note that the code you've provided works just fine under normal circumstances (see: https://play.golang.org/p/lolAe3arl5t), so the information provided in the question is insufficient. You need to provide something that others can reproduce. You need to provide a [mcve]. – mkopriva Sep 10 '21 at 06:15

1 Answers1

-2

It was an error of VS CODE, I highly recommend to use GOLAND by jetbrains for golang