Propagating errors up to the callers is tedious. You end up with many lines looking like:
r, err := os.Open("my file")
if err != nil {
return err
}
This kind of error handling diligence is crucial for writing robust software.
Sometimes you write shorter cmd-line programs where such discipline is not warranted.
You can simplify error handling with a helper functions PanicIfErr(err error, args ...interface{})
:
r, err := os.Open("my file")
PanicIfErr(err)
Implementation of such helper: