summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThibaut Horel <thibaut.horel@gmail.com>2017-06-06 19:22:41 -0400
committerThibaut Horel <thibaut.horel@gmail.com>2017-06-06 19:22:41 -0400
commitc0f04081e638e448af18e030ef00c10001908486 (patch)
treea37e98f4dba6443450e625863c58edc4500b3765
parent53841da448baa28067bab046198757954cebc4a1 (diff)
downloadlastfm-api-c0f04081e638e448af18e030ef00c10001908486.tar.gz
Cleaner closing of transaction
-rw-r--r--data.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/data.go b/data.go
index 30f8a38..373dddb 100644
--- a/data.go
+++ b/data.go
@@ -92,6 +92,7 @@ func (store *SqlStore) PutScrobbles(scrobbles []Scrobble) error {
if err != nil {
return err
}
+
for _, s := range scrobbles {
_, err = st.Exec(s.Artist, s.AlbumArtist, s.TrackName, s.Album,
s.TrackNumber, s.Duration, s.Time, s.Chosen, s.Mbid, s.MbidComp,
@@ -115,6 +116,7 @@ func (store *SqlStore) RecentScrobbles(userId int) []*Scrobble {
if err != nil {
log.Println(err)
}
+ defer rows.Close()
for rows.Next() {
scrobble := new(Scrobble)
@@ -122,6 +124,5 @@ func (store *SqlStore) RecentScrobbles(userId int) []*Scrobble {
&scrobble.TrackName.Name, &scrobble.Time, &scrobble.Image)
scrobbles = append(scrobbles, scrobble)
}
- rows.Close()
return scrobbles
}