Skip to content

False positive on closing rows with external function/method #43

Description

@maksemen2
func deferRows(rows *sql.Rows) {
	err := rows.Close()
	if err != nil {
		log.Error(err)
	}
}

rows, err := db.QueryContext(ctx, "some query", arg1, arg2)
if err != nil {
	...
}
defer deferRows(rows)

will give us an error: error Rows/Stmt/NamedStmt was not closed (sqlclosecheck), although we are closing the rows with external function to avoid code duplicating.

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