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

Set err only when an error occurs. #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

PatrickCronin
Copy link

This code was confusing because it sets err even when closeErr is nil. The PR suggests a modification to clarify the behavior. Alternatively, perhaps adding a comment would be sufficient.

The previous version works, but is confusing. In the event that no error results from `f.Close()` and no error resulted during `io.Copy`, it'd set `err` to `nil` (but `err` was already `nil`). The suggested update removes the cause for my confusion and only sets `err` with the error from `f.Close()` in the event that an error actually occurred from that statement, and leaves in place the consideration that no error had occurred from `io.Copy` as well.
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.

1 participant