Skip to content

Commit

Permalink
checking err!=nil in defer
Browse files Browse the repository at this point in the history
  • Loading branch information
parMaster committed Jul 9, 2024
1 parent 5d6e998 commit bfa71fb
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions storage/sqlite/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@ func (s *SQLiteStorage) GetRecords(ctx context.Context, UUID string) ([]model.Re
return nil, err
}
defer func() {
err := rows.Close()
log.Printf("[ERROR] failed to close rows: %v", err)
if err := rows.Close(); err != nil {
log.Printf("[ERROR] failed to close rows: %v", err)
}
}()

var records []model.Record
Expand Down Expand Up @@ -171,8 +172,9 @@ func (s *SQLiteStorage) GetMeetings(ctx context.Context) ([]model.Meeting, error
return nil, err
}
defer func() {
err := rows.Close()
log.Printf("[ERROR] failed to close rows: %v", err)
if err := rows.Close(); err != nil {
log.Printf("[ERROR] failed to close rows: %v", err)
}
}()

var meetings []model.Meeting
Expand Down Expand Up @@ -210,8 +212,9 @@ func (s *SQLiteStorage) ListMeetings(ctx context.Context) ([]model.Meeting, erro
return nil, err
}
defer func() {
err := rows.Close()
log.Printf("[ERROR] failed to close rows: %v", err)
if err := rows.Close(); err != nil {
log.Printf("[ERROR] failed to close rows: %v", err)
}
}()

var meetings []model.Meeting
Expand Down Expand Up @@ -293,8 +296,9 @@ func (s *SQLiteStorage) GetRecordsByStatus(ctx context.Context, status model.Rec
return nil, err
}
defer func() {
err := rows.Close()
log.Printf("[ERROR] failed to close rows: %v", err)
if err := rows.Close(); err != nil {
log.Printf("[ERROR] failed to close rows: %v", err)
}
}()
var records []model.Record

Expand Down Expand Up @@ -338,8 +342,9 @@ func (s *SQLiteStorage) Stats(ctx context.Context) (map[model.RecordStatus]inter
return nil, err
}
defer func() {
err := rows.Close()
log.Printf("[ERROR] failed to close rows: %v", err)
if err := rows.Close(); err != nil {
log.Printf("[ERROR] failed to close rows: %v", err)
}
}()

stats := make(map[model.RecordStatus]interface{})
Expand Down

0 comments on commit bfa71fb

Please sign in to comment.