Hi Golang newbie coming from Java world. I have this very simple piece of program:
package main
import "fmt"
type Foo struct {
A [5]int
}
func main() {
s := make([]Foo, 0)
var foo Foo
s = append(s, foo)
foo.A[0] = 42
fmt.Printf("%v", s[0].A)
}
However, this prints [0,0,0,0,0] instead of [42,0,0,0,0] that I expected. After swapping the line s = append(s, foo) and foo.A[0] = 42, it does print [42,0,0,0,0]. Why is that? Thanks in advance.