Go Slice Append Example | Golang Append Tutorial is today’s topic. The built-in append function appends any number of elements to the end of a  slice. Append returns the updated slice and it does not modify the existing one. So it is Pure function in terms of Javascript. The resulting value of append() function is a slice containing all the elements of the original slice plus the provided values.

Go Slice Append Example

In Golang, a slice is a reference to the contiguous segment of the array. Slice is the pointer, with additional properties about an array.

A slice is consists of 3 fields.

  • The Pointer to the underlying array.
  • Length of the slice.
  • The capacity of the slice.

Slicing does not copy the slice’s data. It creates the new slice value that points to an original array. It makes slice operations as efficient as manipulating the array indices.

#go #golang

Go Slice Append Example | Golang Append Tutorial
2.20 GEEK