I've been writing some gocode recently and huge chunk of code is if err != nil ... I know you can do if ; err!=nil but that not that much better and you end up in deeply nested if blocks. i have to mentally block out err !=nil to read any gocode linearly. How is this acceptable, I don't get it. https://blog.golang.org/errors-are-values We recently scanned all the open source projects we could find and discovered that…
try:
x := blah()
except Foo:
yadadad
which is worse (IMO) than x, err := blah()
if err != nil {
yadada
}
Besides the extra syntactic clumsiness, it was really hard to know what was going to throw exceptions, and which exceptions, and when. Frequently I would get bugs from unexpectedly thrown exceptions.You said "I have to mentally block out err != nil to read...code" -- for me, the error handling code is code, code I want to pay just as much attention to as the non-error path.
So for that reason I really like Go error handling.
For a client-side script or something, maybe this isn't true; feel free to use log.Fatal or panic if that makes sense for your use case.