Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
close example files after use
  • Loading branch information
dwahler committed May 25, 2022
commit ee7a1fb53ff3de25572ab1661e46a903140022fb
1 change: 1 addition & 0 deletions examples/examples.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ func Archive(exampleID string) ([]byte, error) {
if err != nil {
return xerrors.Errorf("open file %s: %w", path, err)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be closed i.e. defer file.Close()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Technically I think we would be OK without it, because the readers returned by embed.FS are just pointers, but I added it anyway to make the code more obviously correct.

defer file.Close()

err = tarWriter.WriteHeader(header)
if err != nil {
Expand Down