Canonical guidance

Use when

Avoid

Preferred pattern

if err := validate(req); err != nil {
	return err
}

Anti-pattern

Explanation: This is tempting because the code reads linearly, but initializer scope is limited to the statement and its branches.

Why

Related pages

Sources