ryanrolds / sqlclosecheck

Linter that confirms DB rows and statements are closed properly.
MIT License
80 stars 14 forks source link

Support for linting sql.DB calls in methods #32

Closed PiotrZakrzewski-instruqt closed 11 months ago

PiotrZakrzewski-instruqt commented 11 months ago

When linting methods calls to sqlx.DB in form of

func (r *PostgresRepository) Method()  {
    stmt, err := r.db.Prepare("SELECT * FROM TABLE")
}

do not trigger sqlclosecheck. But the following does:

func (r *PostgresRepository) Method()  {
        db := r.db
    stmt, err := db.Prepare("SELECT * FROM TABLE")
}
PiotrZakrzewski-instruqt commented 11 months ago

my bad. It was not flagged because the stmnt was used downstream