Essential Go Slices  Edit on GitHub      File Issue

Duplicate (create a copy of) a slice

src := []int{1, 2, 3}
dst := make([]int, len(src))
copy(dst, src)
fmt.Printf("src: %#v\n", src)
fmt.Printf("dst: %#v\n", dst)
src: []int{1, 2, 3}
dst: []int{1, 2, 3}
  ↑ ↓ to navigate     ↵ to select     Esc to close