I hate that you can't call defer in a loop.
I hate even more that you can call defer in a loop, and it will appear to work, as long as the loop has relatively few iterations, and is just silently massively wasteful.
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.
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.