Re: [go-nuts] A question about copying

2020-07-25 Thread chri...@surlykke.dk
Aha, I see. Thanks for explaining. br. Chr. lørdag den 25. juli 2020 kl. 10.56.35 UTC+2 skrev Jan Mercl: > On Sat, Jul 25, 2020 at 10:09 AM chri...@surlykke.dk > wrote: > > > Is this something I should have deduced from the language spec? > > https://golang.org/ref/s

[go-nuts] A question about copying

2020-07-25 Thread chri...@surlykke.dk
When running this program: package main import ( "fmt" ) type Foo struct { i int } func main() { var f1 = &Foo{i: 0} var f2 = &(*f1) f2.i = 1 fmt.Println(f1, f2) } it yields: &{1} &{1} (https://play.golang.org/p/qKtURokUCEW) I (naively) assumed that the expression &(*f1) would, first, c