Canonical guidance

Use when

Avoid

Preferred pattern

func Clone(in []byte) []byte {
	out := make([]byte, len(in))
	copy(out, in)
	return out
}

Anti-pattern

Explanation: This anti-pattern is tempting because subslices are cheap, but they can retain far more memory than intended.

Why

Related pages

Sources