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
GO Program to Calculate Sum of Natural Numbers Using for.....Loop
How to copy one slice items into another slice in Golang?
Golang HTTP GET request with parameters
Top Programming Languages Behind Blockchain App Development
Cannot use <variable> (type <type>) as type <new-type> error in Golang
How to access slice items in Golang?
How To Make HTTP Requests in Go?
Type assertion in Go Programming Language
How to use WaitGroup to delay execution of the main function until after all goroutines are complete.
Golang program for implementation of AVL Trees