Skip to content

Unnecesary rows.Close() after Query #19

@tomachine

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.

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