Re:More Gotchas of Defer in Go, Part II
by knorker on Friday December 22, 2017 @12:01PM
(#15988929)
Yeah, I could declare it above. But it's subjectively harder to read, having to jump around. Like you say: subjective.
> Your defer as placed in your above example is already scheduled to run always
Yes, brainfart. Sorry. This is from a completely separate recommendation to defer a close (dropping error return), but also manually close so that closing errors can be surfaced. Matters for e.g. writing files (not so much reading), especially when you don't flush manually.
> Your defer as placed in your above example is already scheduled to run always
Yes, brainfart. Sorry. This is from a completely separate recommendation to defer a close (dropping error return), but also manually close so that closing errors can be surfaced. Matters for e.g. writing files (not so much reading), especially when you don't flush manually.