The Go Blog Follow Robust generic functions on slices Avoiding memory leaks in the slices package. https://go.dev/blog/generic-slice-functions go.dev