go的指针引用对象一样,但是地址肯定不一样,值类型相等,指针类型不相等
func main() {
s:=&G{"fsf",19}
y:=new(G)
yw:=new(G)
x:=&G{"fsf",19}
sss,err:=x.Getstr()
if err != nil{
fmt.Println(err)
}
fmt.Println(sss)
w:=s
fmt.Printf("s is ptr:%p\nx is ptr:%p\nw is ptr:%p\n",s,x,w)
fmt.Printf("y is ptr:%p\nyw is ptr:%p",y,yw)
}
s is ptr:0xc000004078
x is ptr:0xc0000040c0
w is ptr:0xc000004078
y is ptr:0xc000004090
yw is ptr:0xc0000040a8
进程 已完成,退出代码为 0