Running this:
emptyslice := []string{}
sh := (*reflect.SliceHeader)(unsafe.Pointer(&emptyslice))
fmt.Printf("empty slice cap = %d\n", sh.Cap)
fmt.Printf("empty slice len = %d\n", sh.Len)
fmt.Printf("empty slice uintptr = %v\n", sh.Data)
Output:
empty slice cap = 0
empty slice len = 0
empty slice uintptr = 824634224152
The non-zero uintptr suggests that something is allocated on the heap. But the cap is 0, so any backing array should have a size of 0. So what is allocated on the heap? Surely not an array of size 0?
mathew