Skip to content

Documentation Request for deferring Close() #8

@Zamiell

Description

@Zamiell

Hello, and thanks for the linter.

sqlclosecheck complains that rows.Close() should use defer. Can you explain why this is? For example, I don't see a difference between:

rows := db.Query("SELECT username FROM users")
for rows.Next() {
	// Do something
}
rows.Close()
return

and

rows := db.Query("SELECT username FROM users")
for rows.Next() {
	// Do something
}
defer rows.Close()
return

Putting defer here just seems confusing / a mistake / superfluous.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions