Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Author here. I absolutely hated writing this piece after shooting myself in the foot a thousand times.

Go's context ergonomics is kinda terrible and currently there's no way around it.



It was a great piece and I learned a lot, thanks for writing it. I hope you didn’t think that it was you I was disappointed with rather than the language designers :)

It’s ironic how context cancellation has the opposite problem as error handling.

With errors they force you to handle every error explicitly which results in people adding unnecessary contextual information: it can be tempting to keep adding layer upon layer of wrapping resulting in an unwieldy error string that’s practically a hand-rolled stacktrace.

With context cancellation OTOH you have to go out of your way to add contextual info at all, and even then it’s not as simple as just using the new machinery because as your piece demonstrates it doesn’t all work well together so you have to go even further out of your way and roll your own timeout-based cancellation. Absurd.


No worries. Your intent was clear. I don't mind the boilerplates if they were footgun free. Context requires you write a bunch of boilerplate where it's still really easy to make mistakes.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: