Skip to content

Commit

Permalink
✅ should check returned error before deferring
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMarble committed Jul 25, 2020
1 parent be18110 commit 345e92d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ func (d *Docker) logs(containerID string, tail string) ([]string, error) {
log.Fatal().Str("module", "docker").Str("containerID", containerID).Err(err).Msg("error getting container logs")
return nil, err
}
defer logsReader.Close()
defer func() {
err := logsReader.Close()
if err != nil {
log.Fatal().Str("module", "docker").Str("containerID", containerID).Err(err).Msg("error closing io.Reader")
}
}()

for {
numBytes, err := logsReader.Read(bytes)
Expand Down

0 comments on commit 345e92d

Please sign in to comment.