Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close via defer #47

Merged
merged 4 commits into from
Mar 27, 2024
Merged

Close via defer #47

merged 4 commits into from
Mar 27, 2024

Conversation

spennymac
Copy link
Contributor

@spennymac spennymac commented Mar 26, 2024

If write were to panic, the file would not get closed. Adding a defer and checking if 'f' is nil prior to closing ensures we will always closethe file and only once.

If write were to panic, the file would not get closed. Adding a defer
and checking if 'f' is nil prior to closing ensures we will always close
the file and only once.
@spennymac spennymac marked this pull request as ready for review March 26, 2024 16:00
util/util.go Outdated Show resolved Hide resolved
util/util.go Outdated Show resolved Hide resolved
@spennymac spennymac requested a review from pjbgf March 26, 2024 19:21
util/util.go Show resolved Hide resolved
Copy link
Member

@pjbgf pjbgf left a comment

Choose a reason for hiding this comment

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

@spennymac thanks for working on this. 🙇

@pjbgf pjbgf merged commit 4d0d7f0 into go-git:master Mar 27, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants