#Handling error in one line
3 messages · Page 1 of 1 (latest)
If it just returns an error, I think it's almost always appropriate
becomes a different story when it's a tuple, consider:
func blah() (error, int) {
return nil, 100
}
func main() {
if err, x := blah(); err != nil { // error, didn't use x within if block
return
}
fmt.Println(x) // error, can't use x here
}