Due the verbose error handling syntax I've created a function check
as below which acts as a "global" error handler. If I want to panic instead to log I change only the check
function. The issue is that now I want to simply return
so that the other go routines can still run if one has an error. So the question is: How can I do that ? Is it possible?
func main() {
for k, v := range foo {
go func() {
err = doSomething()
check("this one failed", err)
}()
}
}
func check(errMsg string, err error) {
if err != nil {
log.Fatalf(errMsg, err)
}
}
However now I've found that I need return the anonymous function if there is any error rather than exit ( log.Fatal
) so I'm wondering if it's possible to return the anyonymou