I find the following function solves all boilerplate issues of error
handling in Go for me:
func panicOn(err error) {
if err != nil { panic(err) }
}
I use it thus:
...
val, err := someFunctionThatCanReturnAnErr()
panicOn(err)
...
When more refined error handling is needed, it can be replaced.
I've never needed anything more, as a defult. Perhaps we should add the
equivalent as a built in, and recommend it to beginners.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/4ee16480-64d8-414b-8a05-30fa5e9a1528n%40googlegroups.com.