title: Append slice to slice of slices
body: <p>I have data structure:</p>
  
  <pre><code>type PosList []int
  
  type InvertedIndex struct {
    Capacity  int
    Len       int
    IndexList []PosList
  }
  </code></pre>
  
  <p>I have problem with Add method: </p>
  
  <pre><code>func (ii *InvertedIndex) Add(posList PosList, docId int) {
    if ii.Len == ii.Capacity {
      newIndexList := make([]PosList, ii.Len, (ii.Capacity+1)*2)
      for i := 0; i &lt; ii.Len; i++ {
        newIndexList[i] = make([]int, len(ii.IndexList[i]))
        copy(newIndexList[i], ii.IndexList[i])
      }
      ii.IndexList = newIndexList
    }
  
    ii.IndexList = ii.IndexList[0 : ii.Len+2]
    ii.IndexList[docId] = posList
    return
  }
  </code></pre>
  
  <p>Or, i try something like this: </p>
  
  <pre><code>func (ii *InvertedIndex) Add(posList PosList, docId int) {
  
    if ii.Len == ii.Capacity {
      newIndexList := make([]PosList, ii.Len, (ii.Capacity+1)*2)
      copy(newIndexList, ii.IndexList)
      ii.IndexList = newIndexList
    }
  
    ii.IndexList = ii.IndexList[0 : ii.Len+2]
    ii.IndexList[docId] = posList
    return
  }
  </code></pre>
  
  <p>Both of them don't work, may be someone can explain how can i append a slice to structure like this. </p>