Hacker News new | ask | show | jobs
by levkk 19 days ago
DropGuard is nice. This is basically `defer` in Go I think.
2 comments

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.
Minus Go's defer being function-scoped, of course.

(and what sibling comment mentioned)