Skip to content

About the scope of the pgx linter #36

Description

@junsred

Pgx apparently closes rows when all rows are read and I guess because of this defer seems not needed. But this shouldn't be the case since function might stop before iterating all the rows. Is this a bug or feature?

	// Next prepares the next row for reading. It returns true if there is another
	// row and false if no more rows are available. It automatically closes rows
	// when all rows are read.
	Next() bool

Code below does not give any errs

var pgxPool *pgxpool.Pool
func missingClosePgxPool() {
	rows, err := pgxPool.Query(context.Background(), "SELECT username FROM users") // want "Rows/Stmt/NamedStmt was not closed"
	if err != nil {
		log.Fatal(err)
	}

	for rows.Next() {
        }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions