Go语言规范中规定了可寻址(addressable)对象的定义,
For an operand x of type T, the address operation &x generates a pointer of type *T to x. The operand must be addressable, that is, either a variable, pointer indirection, or slice indexing operation; or a field selector of an addressable struct operand; or an array indexing operation of an addressable array. As an exception to the addressability requirement, x may also be a (possibly parenthesized) composite literal. If the evaluation of x would cause a run-time panic, then the evaluation of &x does too.
对于一个对象x
, 如果它的类型为T
, 那么&x
则会产生一个类型为*T
的指针,这个指针指向x
, 这是这一段的第一句话,也是我们在开发过程中经常使用的一种获取对象指针的一种方式。