5 ms·
This is such an elegant solution, I'm surprised I don't see it recommended more! I never would have thought to use defer to clean up the error catching noise.
by creatornator 8y ago
This is such an elegant solution, I'm surprised I don't see it recommended more! I never would have thought to use defer to clean up the error catching noise.
- Insanity 7y agoI think the structure as they show it in the end does not survive formatting though. if err != nil { return } would get turned into if err != nil { return } By gofmt. So if you want your code to be well formatted, you still get some visual polution from the error handling there.