Canonical guidance

Use when

Avoid

Preferred pattern

if i < 0 || i >= len(s) {
	return 0, false
}
return s[i], true

Anti-pattern

Explanation: This is tempting when surrounding code “should” be correct, but unguarded panic sites deserve either proof or explicit handling.

Why

Related pages

Sources