title: What is the point in setting a slice's capacity?
body: <p>In Golang, we can use the builtin <code>make()</code> function to create a slice with a given initial length and capacity.</p>
  
  <p>Consider the following lines, the slice's length is set to 1, and its capacity 3:</p>
  
  <pre><code>func main() {
      var slice = make([]int, 1, 3)
      slice[0] = 1
      slice = append(slice, 6, 0, 2, 4, 3, 1)
      fmt.Println(slice)
  }
  </code></pre>
  
  <p>I was surprised to see that this program prints:</p>
  
  <blockquote>
    <p>[1 6 0 2 4 3 1]</p>
  </blockquote>
  
  <p>This got me wondering- what is the point of initially defining a slice's capacity if <code>append()</code> can simply blow past it? Are there performance gains for setting a sufficiently large capacity?</p>