Golang slice is a dynamically-sized, flexible view array. Go slice is a reference to a contiguous segment of an array. Go Slice is basically a pointer, with additional properties about the array. Let me clear one thing here, Golang Slice and Golang Array is totally different data type.

Golang array has a fixed size but Go slice, on the other hand, is a dynamically-sized, flexible view into the elements of an array. A Slice is the segment of an array. The slices build on arrays and provide more power, flexibility, and convenience compared to the arrays.

Unlike the  arrays, slices are typed only by the elements they contain.

Slices support several more that make them richer than  arrays. One of the builtin functions is the  Golang slice append(), which returns a slice containing one or more new values.

#golang #go

Golang Slice Example | Slices in Go Tutorial
1.55 GEEK