From this tutorial shown that rows.Closed()
must be called where rows
is from stmt.Query()
, is stmt.Closed()
also should be called where stmt
is from db.Prepare()
?
// inside a function
stmt, err := db.Prepare(cmd) // cmd is SQL string
Check(err)
// should we add: defer stmt.Close()
rows, err := stmt.Query(params) // params is map/interface{}
defer rows.Close()
Check(err)