How do I print the pointer value of a Go object? What does the pointer value mean?

后端 未结 5 1382
野的像风
野的像风 2020-12-12 11:24

I am just playing around with Go and do not yet have a good mental model of when structs are passed by value or by reference.

This may be a very dumb question but I

5条回答
  •  情深已故
    2020-12-12 12:30

    type sometype struct { }
    a := sometype {}
    b := int(2)
    println("Ptr to a", &a)
    println("Ptr to b", &b)
    

提交回复
热议问题