Growth Factor Of Go Slices
Fast recall
Quick revision
Core answer
Practical understanding of Append And Growth.
Repeating a definition without saying when to use it.
Give one trade-off and say how you would test it.
Interview-ready guide
Interview answer
For small slices, Go grows capacity by about 2x each time capacity is exceeded. A slice created from a 3-element literal grows to 6 when you append a fourth, then to 12, then 24 — you can watch it with cap prints. This is the standard dynamic-array strategy: doubling gives amortized O(1) appends, meaning n appends cost about 2n element-copies total instead of the O(n²) of one-at-a-time growth.
For large slices, the factor shrinks. Doubling a 2GB slice means allocating 4GB — most programs would rather the runtime grow more gently toward 1.25x-ish at those sizes. The exact transition points are runtime-version-specific, which is why the honest interview answer is 'about 2x for small, tapering for large, and an implementation detail you should never depend on.'
Depend on the amortized bound — the language guarantees that — not on any specific capacity sequence. Code that requires cap to be an exact value after growth should allocate its own arrays.
Growth Factor Of Go Slices
Direct Answer
Roughly doubling for small slices — a slice at cap 3 grows to 6, then 12. Growth tapers for very large slices to avoid over-allocating.
Deep Dive & Architecture
Watching the growth live:
s := []int{1} // cap 1
s = append(s, 2) // 1→2
s = append(s, 3) // 2→4
s = append(s, 4)
s = append(s, 5) // 4→8
for len(s) <= 20 {
s = append(s, 0)
}
fmt.Println(cap(s)) // powers of two: 32 (on this run)
Each print shows the runtime's next tier. The sequence is stable for small sizes, which is why tutorials show it — but the runtime reserves the right to change the schedule (and has, across versions), so the sequence is an observation, not a contract.
The amortized bound is the contract: append is O(1) average, with occasional O(n) copies when the tier boundary is crossed. Pre-sizing (the earlier question) doesn't change the bound — it just deletes the copies for a known n. For unknown n, doubling is mathematically the least-copy schedule for growth-by-append, which is why every major dynamic array (Go slices, C++ vector, Python list, Java ArrayList) uses it.
Common Mistakes & Pitfalls
Repeating a definition without saying when to use it.
Check your understanding
Answer these without looking back at the article.
- What is Append And Growth, and when would you use it?
- When would you use Append And Growth in a real project?
- How would you compare Append And Growth with an alternative?
Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.