What is the difference between cap and len of a slice in golang?
According to definition:
A slice has both a length and a capacity.
The length of a slice
You've answered your question - the length of the underlying array in a slice is not necessarily the same as the number of elements that array contains.