How can I add elements to slice reflection?
<p>Hi i am learning <code>Go</code> and i was doing some reflection. I got stuck in a case like this:</p>

<ol>
<li>I want to create a <code>slice</code> of <code>struct</code> passed to function as <code>interface{}</code></li>
<li>Then I want to append new elements to this slice</li>
</ol>

<p>Here is a <a href="https://play.golang.org/p/Kmbw5_Oine" rel="nofollow">playground</a> with the code example.</p>

<pre><code>package main

import (
    "fmt"
    "reflect"
)

type A struct{ Name string }

func main() {
    bbb(A{})
}

func aaa(v interface{}) {
    sl := reflect.ValueOf(v).Elem()
    typeOfT := sl.Type()

    ptr := reflect.New(typeOfT).Interface()
    s := reflect.ValueOf(ptr).Elem()
    sl.Set(reflect.Append(sl, s))

    ptr = reflect.New(typeOfT).Interface()
    s = reflect.ValueOf(ptr).Elem()
    sl.Set(reflect.Append(sl, s))
}

func bbb(v interface{}) {
    myType := reflect.TypeOf(v)
    models := reflect.Zero(reflect.SliceOf(myType)).Interface()
    aaa(&amp;models)

    fmt.Println(models)
}
</code></pre>

<p><strong>Error:</strong> <code>panic: reflect: call of reflect.Append on interface Value</code></p>

<p>Is there a way to make it work ? 
Note: that i want to work on a reference.</p>

<p><strong>Solution:</strong></p>

<p>Here is what i manage to do: <a href="https://play.golang.org/p/3mIEFqMxk-" rel="nofollow">playground</a>.</p>