The internals of slice

There are 3 components of slice: a) Pointer: Points to the start position of slice in the underlying array; b) length (type is int): the number of the valid elements of the slice; b) capacity (type is int): the total number of slots of the slice. Check the following code: package main import ( "fmt" "unsafe" ) func main() { var s1 []int fmt.Println(unsafe.Sizeof(s1)) } The result is 24 on my 64-bit system (The pointer and int both occupy 8 bytes). [Read More]