Slice

A slice is formed by specifying two indices, a lower bound and an upper bound, separated by a colon:


the[first:last]
                        

This selects a half-open range that includes the first element but excludes the last.

A new initialized slice value for a given type of T element is made using a built-in function make, which takes a slice type and parameters specifying the length and, optionally, the capacity.

A slice created with make always allocates a new hidden array to which the returned slice value refers.


make([]T, length, capacity)
                        
slice_type.go