3 ms·
Since the Go 1.14 optimizations I don't believe I've found a single case where `X(); defer Unx()` has been worse. Unfortunately this was not the case before 1.
by morelisp 4y ago
Since the Go 1.14 optimizations I don't believe I've found a single case where `X(); defer Unx()` has been worse.
Unfortunately this was not the case before 1.14, so there's a lot of "middle-aged" code floating around setting a bad example.
- klodolph 4y agoOld habits die hard. For what it’s worth, the bugs I saw were long before the 1.14 release. Somewhere around 1.7 or something.
- morelisp 4y agoAgreed - it's also not nearly as clear for `ctx, cancel := ...; defer cancel()` and I see that reflex in a few places where it's not only often much less efficient, but logically wrong / less safe.
- klodolph 4y agoWhat issues do you see with defer cancel()?
- preseinger 4y agoI think the OP is saying defer cancel() is correct, and the stuff people would do to avoid it are the things that are bad.