News for hackers. Stuff that matters.
Re:Map[string]interface{} in Go: a user's manual by tgsovlerkhgsel on Monday July 26, 2021 @06:23PM (#27966222)
I kept the example simple, of course I could now customize the error message further (or take some other sensible action). Note that I returned a 400, not a generic 502 here. If I didn't care at all, I wouldn't need any extra lines. Does the panic handler send a response at all, or does it just drop the connection?

Also, in Go, using panic/recover is considered unidiomatic. You can use it like an exception system, but it's not what you're supposed to do.

Re:Map[string]interface{} in Go: a user's manual by tptacek on Monday July 26, 2021 @06:29PM (#27966266)
I'm not suggesting that you would build a custom exception recovery system; I'm pointing out that net/http, which is definitionally idiomatic, already has that recovery mechanism.
Re:Map[string]interface{} in Go: a user's manual by tgsovlerkhgsel on Monday July 26, 2021 @07:01PM (#27966558)
I believe that that recovery mechanism isn't supposed to be routinely triggered just due to bad user input, and that code that does so would be considered defective.
Re:Map[string]interface{} in Go: a user's manual by tptacek on Monday July 26, 2021 @08:36PM (#27967284)
It's doing almost literally the same thing as the Python code upthread. Just, with less code.