Re: [go-nuts] slice: copy to zero length slice
No, it should not operate that way. Remember that all function calls in Go pass arguments by value. A slice is actually a value somewhat analogous to type SliceOfT struct { Data*T Len int Cap int } When
[go-nuts] slice: copy to zero length slice
As official doc explains, copy to zero length slice results to be empty. package main import "fmt" func main() { src := []int{1, 2, 3} dst := []int{} fmt.Println(len(dst)) copy(dst, src) fmt.Println(src) fmt.Println(dst) // [1 2 3] // [] src2 := []int{1, 2, 3