Closed tadvi closed 4 years ago
This is small function and benefits might not be obvious.
Go way is to "prefer early return". That means returning from the function on error early. It also means checking for err != nil .
func AddErr(errs *[]error, err error) bool { if err == nil { return true } else { *errs = append(*errs, err) return false } }
// idiomatic Go checks for err != nil // Also prefer "early return"
func AddErr(errs *[]error, err error) bool { if err != nil { *errs = append(*errs, err) return false } return true }
Fixed
This is small function and benefits might not be obvious.
Go way is to "prefer early return". That means returning from the function on error early. It also means checking for err != nil .
// idiomatic Go checks for err != nil // Also prefer "early return"