-
Notifications
You must be signed in to change notification settings - Fork 295
Check for errors when trying to create the auth token file #447
Check for errors when trying to create the auth token file #447
Conversation
Codecov Report
@@ Coverage Diff @@
## master #447 +/- ##
==========================================
- Coverage 41.02% 41.01% -0.01%
==========================================
Files 38 38
Lines 2679 2682 +3
==========================================
+ Hits 1099 1100 +1
- Misses 1420 1421 +1
- Partials 160 161 +1
Continue to review full report at Codecov.
|
if err != nil { | ||
return nil, err | ||
} | ||
defer file.Close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you never use file
, why defer
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@redbaron I just wanted to make sure all handles were closed properly. Is this unnecessary in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defer
delays file.Close()
until function exits. you don't use file
anywhere, so close it right there, without defer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@redbaron done! Thanks for your feedback.
The file is not being used after it's created/opened, so there's no reason to defer the closing.
…s-retired#447) * Check for errors when trying to create the auth token file * Close the file right away, instead of closing with `defer` The file is not being used after it's created/opened, so there's no reason to defer the closing.
@mumoshu addressing your comment in my last PR #439.