4 ms·
> silently handling panics That has a bad smell
by tomohawk 6y ago
> silently handling panics
That has a bad smell
- partiallattice 6y agoEspecially since caught panics amount to exceptions and most Golang code isn't exception safe. It's a recipe for leaking database connections, deadlocks, etc.
- TheDong 6y agoGo error handling is awful, but this isn't a fair. In go, if you write code like the following: conn, err := db.Connect() defer conn.Close() That defer will be run during a panic. Same thing as 'defer mutex.Unlock()' Yes, like most of go, it's manual and painful and poorly thought out, but most people do follow these patterns, so for the most part go code will safely unwind from a panic.
- partiallattice 6y agoMost of the time, sure, but there are lots of cases where `defer` being function scoped leads to manual unlocks, e.g. inside loops or short critical sections in the middle of a function. Yes, you can use closures/otherwise, but few codebases are that disciplined. Those edge cases are plentiful enough that catching panics is dangerous.
- sethammons 6y agoI assume they meant “automatic handling of panics.” Unless that framework has interesting defaults. On mobile, else I’d check.