Issue with Sqlc auto generated code golang

923 Views Asked by At
/ 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

There are 1 best solutions below

2
On

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