diff options
-rw-r--r-- | doc/effective_go.html | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/doc/effective_go.html b/doc/effective_go.html index ce5fcb99d..415ae0962 100644 --- a/doc/effective_go.html +++ b/doc/effective_go.html @@ -1070,10 +1070,8 @@ func Append(slice, data[]byte) []byte { if l + len(data) > cap(slice) { // reallocate // Allocate double what's needed, for future growth. newSlice := make([]byte, (l+len(data))*2) - // Copy data (could use bytes.Copy()). - for i, c := range slice { - newSlice[i] = c - } + // The copy function is predeclared and works for any slice type. + copy(newSlice, slice) slice = newSlice } slice = slice[0:l+len(data)] |