Canonical guidance

Use when

Avoid

Preferred pattern

type Counter struct {
	n int
}

func (c *Counter) Inc() { c.n++ }

Anti-pattern

Explanation: This is tempting because the element looks like an lvalue, but map indexing does not produce an addressable value.

Why

Related pages

Sources