logoalt Hacker News

levkk • yesterday at 10:50 PM • 2 replies • view on HN

DropGuard is nice. This is basically `defer` in Go I think.


Replies

Groxx • yesterday at 11:09 PM

A defer that you can explicitly skip (via `dismiss()`) - I like it, that'd clean up a fair bit of "do this for safety unless successful" Go code that I've encountered. I've built similar things before, sometimes it helps a lot, and often that's in especially gnarly code which generally benefits from any clarity improvement.

aw1621107 • yesterday at 11:59 PM

Minus Go's defer being function-scoped, of course.

(and what sibling comment mentioned)