go: Close all DB results

master
Luther Wen Xu 2019-10-10 20:40:24 +07:00
parent 907b6d889b
commit 3709d0698b
Signed by untrusted user: chanbakjsd
GPG Key ID: B7D77E3E9D102B70
2 changed files with 5 additions and 0 deletions

@ -9,6 +9,7 @@ func getInviteOwner(inviteCode string) (string, error) {
if err != nil {
return "", err
}
defer rows.Close()
if rows.Next() {
var owner string
var used bool

@ -27,6 +27,7 @@ func getVoteName(id int) (string, error) {
if err != nil {
return "", err
}
defer rows.Close()
if rows.Next() {
var name string
err := rows.Scan(&name)
@ -43,6 +44,7 @@ func getVoteFromMessageID(msgID string) (int, error) {
if err != nil {
return 0, err
}
defer rows.Close()
if rows.Next() {
var id int
err := rows.Scan(&id)
@ -64,10 +66,12 @@ func updateVote(voteID int, userID string, voteValue int) error {
if rows.Next() {
return errForceRejectionVoteReuse
}
rows.Close()
}
//Check if the vote is finished and don't allow change of vote that way.
rows, err := db.Query("SELECT finished FROM vote WHERE id=? AND finished=?", voteID, true)
defer rows.Close()
if rows.Next() {
return errVoteIsOver
}