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-26T09:39:59Z

Updated

2019-03-26T09:39:59Z

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