What is the fastest way to append one array to another in Go?
问题 Suppose that I have arrays A and B in Go. What is the fastest way to append all the values of B to A ? 回答1: Arrays in Go are secondary, slices are the way to go. Go provides a built-in append() function to append slices: a := []int{1, 2, 3} b := []int{4, 5} a = append(a, b...) fmt.Println(a) Output: [1 2 3 4 5] Try it on the Go Playground. Notes: Arrays in Go are fixed sizes: once an array is created, you cannot increase its size so you can't append elements to it. If you would have to, you