DEV Community

[Comment from a deleted post]
Collapse
 
ladydascalie profile image
Benjamin Cable

Just one small nitpick:

you should call defer file.Close() after you've performed your error check.
If you failed to open a file, then there's no need to try and close it!

Collapse
 
shiraazm profile image
Shiraaz Moollatjie

Makes sense. Thanks for highlighting it to me :)

Updated the example.