Canonical guidance

Use when

Avoid

Preferred pattern

if err == nil {
	return nil
}
return err

Anti-pattern

var e *MyError = nil
return e

Explanation: This anti-pattern is common because a nil pointer looks nil in the debugger, but once wrapped in an interface it can change control flow unexpectedly.

Why

Sources