title: Slicing: Out of bounds error in Go
body: <pre><code>package main
  
  import "fmt"
  
  func main() {
      a := make([]int, 5)
      printSlice("a", a)
      b := make([]int, 0, 5)
      printSlice("b", b)
      c := b[1:]
      printSlice("c", c)
  }
  
  
  func printSlice(s string, x []int) {
      fmt.Printf("%s len=%d cap=%d %v\n",
          s, len(x), cap(x), x)
  }
  </code></pre>
  
  <p>The above gives me an out of bounds error:</p>
  
  <pre><code>a len=5 cap=5 [0 0 0 0 0]
  b len=0 cap=5 []
  panic: runtime error: slice bounds out of range
  
  goroutine 1 [running]:
  main.main()
     /private/var/folders/q_/53gv6r4s0y5f50v9p26qhs3h00911v/T/compile117.go:10 +0x150
  </code></pre>
  
  <p>Why is the slicing expression to create the <code>c</code> slice results in an error?</p>