3 ms·
Yes, but that is definitely not achieved by checking for errors every second line.
by kaba0 5y ago
Yes, but that is definitely not achieved by checking for errors every second line.
- philosopher1234 5y agoI think checking for errors every line makes my go programs easier and faster to produce at a higher level of quality.
- valand 5y agoSome languages achieve error checking by type transforms and pattern matching, which are much more effective and efficient than error checks after every function call
- chrisoverzero 5y agoSure, but is writing the error check by hand what creates the benefit? Or is it having the error check?
- lanstin 5y agoIt is thinking about what to do for each operation that can fail. This thought is what separates the applications that recover when the network glitch is over vs. the applications that need to be restarted.
- lanstin 5y agoThe value here is the few seconds of human attention given to the error at hand. The thought is irreplaceable. Like others mention, 90% of the, end up if err != nil { return nil, err } but thinking about it will, in my experience, make the system more robust to failure. At the very Least for your process you will decide on a goal of carrying on in the face of failures and repairing when things work again vs. just bailing out and letting something else worry about it.
- kaba0 5y agoWhat if the return nil, err was the sane choice at the time of writing but there are changes downstream that mandate a new error handling mode there? Also, there are plenty of “writing this code at 3AM” where I would question the validity of such thoughts.