Skip to content

Commit

Permalink
Ensure that log files are closed after opening.
Browse files Browse the repository at this point in the history
  • Loading branch information
林志宇 committed May 9, 2019
1 parent deab19c commit 06322ac
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/transport/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func (tls *fileTransportLogStore) Entry(id uuid.UUID) (*LogEntry, error) {
if err != nil {
return nil, fmt.Errorf("open: %s", err)
}
defer func() { _ = f.Close() }() //nolint:errcheck

entry := &LogEntry{}
if err := json.NewDecoder(f).Decode(entry); err != nil {
Expand All @@ -85,6 +86,7 @@ func (tls *fileTransportLogStore) Record(id uuid.UUID, entry *LogEntry) error {
if err != nil {
return fmt.Errorf("open: %s", err)
}
defer func() { _ = f.Close() }() //nolint:errcheck

if err := json.NewEncoder(f).Encode(entry); err != nil {
return fmt.Errorf("json: %s", err)
Expand Down

0 comments on commit 06322ac

Please sign in to comment.