https://go.dev/tour/moretypes/15
in this go tour tutorial, it is not explained why after each append, length and capacity are the same until the last one, where length is 5 and capacity is somehow 6? why is it different then any other append before it?
this is the output after running the sample code
len=0 cap=0 []
len=1 cap=1 [0]
len=2 cap=2 [0 1]
len=5 cap=6 [0 1 2 3 4]
Can you explain based on current version of go as of 2024-03-19 How does Go slice capacity change on append? as this question suggest, it is dependent on versions of go as of 2019, have this behavior changed in 2024 version of go ?
in a similar question from 10 years ago How the slice is enlarged by append? Is the capacity always doubled?
As of 2014-2020 the implemented rules are:
it has been updated until 2020, a lot could have changed in golang since last 4 years, I feel like it is a valid question to revisit it since a decade ago and not a duplicate, as one of the answer literally says
But as you can see looking into the history it can't be relied to stay the same over time.