Re:Twelve Years of Go
by thatswrong0 on Friday November 12, 2021 @04:36PM
(#29204827)
> It lets me start fresh and restart my mental model with the line of codes below the error handling block.
My code is almost exactly:
err := doThing()
if err != nil {
return err
}
err = doAnotherThing()
if err != nil {
return err
}
etc.
There's no need for me to "start fresh". Each line of actual stuff doing might return an error which needs to be returned. That's it. It's a complete waste of space and inhibits readability to absolutely no benefit. And this is extremely common across our code base.
My code is almost exactly:
err := doThing()
if err != nil {
}err = doAnotherThing()
if err != nil {
}etc.
There's no need for me to "start fresh". Each line of actual stuff doing might return an error which needs to be returned. That's it. It's a complete waste of space and inhibits readability to absolutely no benefit. And this is extremely common across our code base.