logoalt Hacker News

usrnmyesterday at 10:18 AM1 replyview on HN

The go way of dealing with it is wrapping the block with your defers in a lambda. Looks weird at first, but you can get used to it.


Replies

mort96yesterday at 10:21 AM

I know. Or in some cases, you can put the loop body in a dedicated function. There are workarounds. It's just bad that the wrong way a) is the most obvious way, and b) is silently wrong in such a way that it appears to work during testing, often becoming a problem only when confronted with real-world data, and often surfacing only as being a hard-to-debug performance or resource usage issue.

show 2 replies