Skip to content

Unnecesary rows.Close() after Query #19

Description

@tomachine

When using db.Query(query) the Rows/Stmt was not closed error appears, even though I'm checking the Err() method.
The documentation says that Close() is called automatically and checking of Err() is sufficient.

Expected: No linter error when not calling Close() excplicitly and checking using Err() method.
Actual: Not closed linter error

image (2)
image (3)

rows, err := d.db.Query(query)
if err != nil {
    return nil, err
}

for rows.Next() {
    //do something
}

if rows.Err() != nil {
    return nil, err
}

This code results in no close error.

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

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions