slice: introduce common Copy helper

It's a bit more convenient to use.
This commit is contained in:
Roman Khimov 2021-07-18 16:32:10 +03:00
parent a54e3516d1
commit 19717dd9a8
14 changed files with 51 additions and 65 deletions

View file

@ -21,3 +21,10 @@ func reverse(dst []byte, src []byte) {
dst[i], dst[j] = src[j], src[i]
}
}
// Copy copies the byte slice into new slice (make/copy).
func Copy(b []byte) []byte {
d := make([]byte, len(b))
copy(d, b)
return d
}