sqlclosecheck
sqlclosecheck copied to clipboard
Linter that confirms DB rows and statements are closed properly.
Because, quoting documentation, "The statements prepared for a transaction by calling the transaction's Prepare or Stmt methods are closed by the call to Commit or Rollback.". https://pkg.go.dev/database/sql#Tx Linter should avoid...
The sql.Row structs returned by the QueryRow methods contain a reference to a sql.Rows instance that is only closed when Scan is called. (see https://cs.opensource.google/go/go/+/refs/tags/go1.17.3:src/database/sql/sql.go;l=3326) Thus i think that this...
sqlclosecheck doesn't work correctly in this case. #20 - a concrete test case. Maybe this approach of dealing with Stmt is not good, but we have some small go scripts...
I meet the case that someone write ```go if err := conn.QueryRow(query, args...).Error(); err != nil { } ``` the conn leaks. In fact, he wants to Exec(query, args...). I...