I expected the following code snippet either to produce a
as {0x01, 0x02}
(pass by value) or as {0x03, 0x02, 0x01}
(pass by reference). Strangely, it produces the output as {0x03, 0x02}
. Could you please help me understand why is that?
package main
import "fmt"
func test1(t []byte) {
t[0] = 0x03
t = append(t, 0x01 )
}
func main() {
a := []byte{0x01, 0x02 }
test1(a)
_ = a
fmt.Printf("%v", a)
}