passing slice as a reference to reflect changes in caller : <p>main declares a slice with name <code>allOutputs</code> (i believe its a slice of strings, not an array of strings) with zero length and 100 capacity. Then it appends a string with value "abcd" and calls myTest function which updates the array[0] with "1234" and then does an append with value "5678".</p>

<p>When i printed <code>allOutputs</code> after <code>myTest</code> call, i correctly see the element at the first index has an updated value of "1234". This tells me that myTest got slice as reference. But the later <code>append</code> of <code>"5678"</code> is not seen by the caller (main here) at all why its so? Remember the original slice is backed by an array with a capacity of 100. Why can't i see 5678 in main when the slice is passed by a reference?</p>

<p>In other words, how exactly the append works?</p>

<pre><code>import "fmt"

func myTest(array []string) {
    array[0] = "1234"
    array = append(array, "5678")
}

func main() {
    allOutputs := make([]string, 0, 100)
    allOutputs = append(allOutput, "abcd")
        fmt.Println(allOutputs) // Println1
    myTest(allOutputs)
    fmt.Println(allOutputs) // Println2
}
</code></pre>

<p>ACTUAL OUTPUT:
[1234]</p>

<p>I EXPECTED:
[1234, 5678]</p>
