When calling json.Unmarshal(data, &list.elements) the cap(list.elements) is usually larger than the actual length. In that case the check in the growBy function fails and list.elements size is not adjusted.
Maybe I'm missing something here but from what I can tell, the resize function always ensures that the length is equal to the capacity.
When calling
json.Unmarshal(data, &list.elements)
thecap(list.elements)
is usually larger than the actual length. In that case the check in thegrowBy
function fails andlist.elements
size is not adjusted. Maybe I'm missing something here but from what I can tell, theresize
function always ensures that the length is equal to the capacity.