How append a slice to an existing slice in Golang?


The usage of triple-dot ... ellipsis used to append a slice.

Example

package main

import "fmt"

func main() {
	var slice1 = []string{"india", "japan", "canada"}
	var slice2 = []string{"australia", "russia"}

	slice2 = append(slice2, slice1...)
}
Most Helpful This Week