What is the difference between these two structures, except that they are not considered equivalent?
package main import "fmt" func main() { a := struct{int}{1} b := struct{int int}{1} fmt.Println(a,b) a.int=2 b.int=a.int fmt.Println(a,b)
They look the same:
$ go run a.go {1} {1} {2} {2}
But if you uncomment a = b , it says:
$ go run a.go
However, struct{a,b int} and struct{a int;b int} equivalent:
package main func main() { a := struct{a,b int}{1,2} b := struct{a int;b int}{1,2} a = b b = a }
?
source share