diff options
Diffstat (limited to 'src/bytes/bytes.go')
| -rw-r--r-- | src/bytes/bytes.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/bytes/bytes.go b/src/bytes/bytes.go index 659a82bcc8..27834fc6db 100644 --- a/src/bytes/bytes.go +++ b/src/bytes/bytes.go @@ -1299,3 +1299,13 @@ func Cut(s, sep []byte) (before, after []byte, found bool) { } return s, nil, false } + +// Clone returns a copy of b[:len(b)]. +// The result may have additional unused capacity. +// Clone(nil) returns nil. +func Clone(b []byte) []byte { + if b == nil { + return nil + } + return append([]byte{}, b...) +} |
