📌  相关文章
📜  golang copy struct - Go 编程语言代码示例

📅  最后修改于: 2022-03-11 14:45:00.682000             🧑  作者: Mango

代码示例1
type Person struct{
  Name string
  Age  int
}

alice1 := Person{"Alice", 30}
alice2 := alice1
fmt.Println(alice1 == alice2)   // => true, they have the same field values
fmt.Println(&alice1 == &alice2) // => false, they have different addresses

alice2.Age += 10
fmt.Println(alice1 == alice2)   // => false, now they have different field values