diff options
| author | Thibaut Horel <thibaut.horel@gmail.com> | 2017-06-06 19:22:41 -0400 |
|---|---|---|
| committer | Thibaut Horel <thibaut.horel@gmail.com> | 2017-06-06 19:22:41 -0400 |
| commit | c0f04081e638e448af18e030ef00c10001908486 (patch) | |
| tree | a37e98f4dba6443450e625863c58edc4500b3765 | |
| parent | 53841da448baa28067bab046198757954cebc4a1 (diff) | |
| download | lastfm-api-c0f04081e638e448af18e030ef00c10001908486.tar.gz | |
Cleaner closing of transaction
| -rw-r--r-- | data.go | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -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 } |
