title: How to determine the element type of slice interface{}?
body: <p>I have the following code to double the slice.</p>
  
  <pre><code>func doubleSlice(s []int) []int  {
    t := make([]int, len(s), (cap(s) + 1) * 2 )
    for i := range s {
      t[i] = s[i]
    }
    return t
  }
  </code></pre>
  
  <p>I want to make the func to double any type of slice. And I need to know the element type first.</p>
  
  <pre><code>func showInterfaceItem(s interface{}) interface{} {
    if reflect.TypeOf(s).Kind() != reflect.Slice {
      fmt.Println("The interface is not a slice.")
      return
    }
  
    var t interface{}
    newLen := reflect.ValueOf(s).Len()
    newCap := (cap(reflect.ValueOf(s).Cap()) + 1) * 2
    t = make([]reflect.TypeOf(s), newLen, newCap)
  
    return t
  }
  </code></pre>
  
  <p>The <code>reflect.TypeOf(s)</code> return the type of interface{}, not the type of element. How can I get the element type of slice interface?</p>