In the code snippet below, how to initialize an error variable?
err := nil
if xxx {
err = funcA()
} else {
err = funcB()
}
if err != nil {
panic(err)
}
As you can see above, it errwill be used in if-else blocks. I want to use one variable to get the result, but how do I initialize errhere. Thank you
source
share