Created
March 25, 2020 20:24
-
-
Save olehcambel/73b51ec3dc6f47af087a16a4648d8304 to your computer and use it in GitHub Desktop.
go copy impl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func copy(dst, src []T) int { | |
for i := range dst { | |
src[i] = dst[i] | |
} | |
return cap(dst) - cap(src) | |
} | |
t := make([]byte, len(s), (cap(s)+1)*2) | |
copy(t, s) | |
s = t |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment