nil
value CRT-D0013267// resolver in error messages, which is super confusing for users.
268func fixNameError(err error, ns string) error {
269 if err == nil {
270 return err271 }
272 return errors.New(nameErrorRx.ReplaceAllString(err.Error(), fmt.Sprintf("[%s]:53", ns)))
273}
If a return statement returns a value that evaluates to nil
, it is better to
return nil
explicitly.
Explicitly returning nil
improves the program's readability and helps
programmers know that they are returning nil
.
if err == nil {
return err
}
if err == nil {
return nil
}
if err != nil {
return err
}
// ...
return nil