diff options
| author | Shulhan <ms@kilabit.info> | 2019-03-05 10:30:57 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2019-03-05 10:34:38 +0700 |
| commit | 9bfb10a655bb94fd99b575dd3523d8f5003cb78b (patch) | |
| tree | cb2012aa5dfaffd3dcb6de07400e40acd418a117 /lib/bytes/bytes.go | |
| parent | 8b84b595ad1956bbe9a0c58c7e67aea0576d3559 (diff) | |
| download | pakakeh.go-9bfb10a655bb94fd99b575dd3523d8f5003cb78b.tar.xz | |
bytes: change the Copy return type to non pointer
Non pointer slice is less confusing than with pointer.
Diffstat (limited to 'lib/bytes/bytes.go')
| -rw-r--r-- | lib/bytes/bytes.go | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/bytes/bytes.go b/lib/bytes/bytes.go index 5c9da0be..94208a5e 100644 --- a/lib/bytes/bytes.go +++ b/lib/bytes/bytes.go @@ -101,13 +101,12 @@ func Concat(sb []byte, args ...interface{}) (out []byte) { // // Copy slice of bytes from parameter. // -func Copy(src []byte) (dst *[]byte) { +func Copy(src []byte) (dst []byte) { if len(src) == 0 { - return nil + return } - cp := make([]byte, len(src)) - copy(cp, src) - dst = &cp + dst = make([]byte, len(src)) + copy(dst, src) return } |
