Quick actions

cmd+k|ctrl+k

Navigation

Languages

Slices / Duplicate (create a copy of) a slice / Essential Go

Snippet info

Language

Go

Visibility

public

Author

kkowalczyk

Created

2019-03-10T23:32:02Z

Updated

2019-03-10T23:32:02Z

package main

import "fmt"

func main() {
	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)
}
INFO