Working directly with []byte is very common and needing to copy it comes up fairly often. A Clone helper would be nice to have.
What did you expect to see?
What did you see instead?
dup := make([]byte, len(data))
copy(dup, data)
Implementation
package bytes
// Clone returns a copy of b
func Clone(b []byte) []byte {
b2 := make([]byte, len(b))
copy(b2, b)
return b2
}
Working directly with
[]byteis very common and needing to copy it comes up fairly often. AClonehelper would be nice to have.What did you expect to see?
What did you see instead?
Implementation