I couldn't find it in the runtime, but I am wondering how go decides how much memory is likely to be needed when reallocating maps or slices. So when we look at this (same would apply to slices):
test := map[int]string{}
for i := 0; i < 1000; i++ {
test[i] = fmt.Sprintf("test-%d", i)
}
How much memory will be allocated at first and how many reallocations take place during the loop?
I am asking this because I am trying to figure out if there are cases where it makes sense to apply a custom reallocation strategy (i.e. use an array instead of a slice and grow the array when needed by a factor which likely meets my application's requirements).