Slice append function in Go

Append an element to the slice:

1
2
nums := []int{1, 2, 3}
nums = append(nums, 4)

Append multiple elements to the slice:

1
2
nums := []int{1, 2}
nums = append(nums, 3, 4)

Append slice to another slice:

1
2
3
4
5
nums := []int{1, 2}
tens := []int{11, 12}
nums = append(nums, tens...)

// nums is {1, 2, 11, 12}