compiler: implement builtin copy(dst, src []T)

Not implemented: copying a string into a []byte slice.
This commit is contained in:
Ayke van Laethem
2018-09-06 10:37:44 +02:00
parent fd9fa038a9
commit 5aa8b71ae1
3 changed files with 55 additions and 1 deletions
+3 -1
View File
@@ -37,11 +37,13 @@ func main() {
// slice
l := 5
foo := []int{1, 2, 4, 5}
bar := make([]byte, l-2, l)
bar := make([]int, l-2, l)
println("len/cap foo:", len(foo), cap(foo))
println("len/cap bar:", len(bar), cap(bar))
println("foo[3]:", foo[3])
println("sum foo:", sum(foo))
println("copy foo -> bar:", copy(bar, foo))
println("sum bar:", sum(bar))
// interfaces, pointers
thing := &Thing{"foo"}