3 ms·
Some of the error handling examples in Go are unnecessary as Go allows you to access variable defined in your if-statement in other branches. For instance:
by rcme 4y ago
Some of the error handling examples in Go are unnecessary as Go allows you to access variable defined in your if-statement in other branches. For instance:
if result, err := something(); err == nil {
if result.RowsAffected() == 0 {
return nil
}
} else if err != nil {
return err
}