Consider wanting to dynamically fill an array/slice with exactly 5
elements. No more, and no less.
sl := []string{}
for i := 0; i < 5; i++ {
sl = append(sl, "abc")
}
sl := make([]string, 5)
for i := 0; i < 5; i++ {
s1[i] = "abc"
}
sl := make([]string, 5, 5)
for i := 0; i < 5; i++ {
sl[i] = "abc"
}
My feeling tells me that #1 is not the best solution, but I am wondering why I would choose #2 over #3 or vice versa? (performance-wise)