You can use ...
operator to append to the other end of the slice sections:
package main import ( "fmt" ) func main() { veggies := []string{"potatoes","tomatoes","brinjal"} fruits := []string{"oranges","apples"} food := append(veggies, fruits...) fmt.Println("food:",food) }
The above procedure , in the first 10 rows fruits
appended to veggies
and assigned to food
. ...
Operator is used to expand the slice. The output of the program food: [potatoes tomatoes brinjal oranges apples]
is: .