GOLANG copy
作者:互联网
golang 中 copy 函数用于合并两个切片; func copy(dst, src []Type) int 注意copy的长度是dest 和 src 中最小的长度值;
package main import ( "fmt" ) func main() { src := []int{1, 2} dest := []int{} copy(dest, src) fmt.Println(dest) // [] }
package main import ( "fmt" ) func main() { src := []int{1, 2} dest := make([]int, 1) copy(dest, src) fmt.Println(dest) // [1] }
标签:src,main,dest,fmt,GOLANG,int,copy 来源: https://www.cnblogs.com/buray/p/16210427.html