I am new to Golang and I've seen it is very common to check for errors all the time. I am trying to find a way to not have my code polluted with "if error { log... }" or "if error { exit }". What do you think of a function like:
fun exitIfError(error err) {
if error != nil {
exit(1)
}
}
That body of the function would be otherwise spread throughout the main function several times, but it would probably make less explicit where the program exits, any opinions?
err = fallibleOperation(); if err != nil { return err }
pattern tofallibleOperation()?