https://stackoverflow.com/questions/30182538/why-cant-i-duplicate-a-slice-with-copy
The builtin copy(dst, src) copies min(len(dst), len(src)) elements.
So if your dst is empty (len(dst) == 0), nothing will be copied.
Try tmp := make([]int, len(arr)) (Go Playground):
Unfortunately this is not documented in the builtin package, but it is documented in the Go Language Specification: Appending to and copying slices:
The number of elements copied is the minimum of len(src) and len(dst).
Edit:
Finally the documentation of copy() has been updated and it now contains the fact that the minimum length of source and destination will be copied:
Copy returns the number of elements copied, which will be the minimum of len(src) and len(dst).
複製返回複製的元素數量,該數量將是len(src)和len(dst)的最小值。
測試:https://play.golang.org/p/Q1KmOtE2rR5