Why can't I assign type's value to an interface implementing methods with receiver type pointer to that type?

前端 未结 4 1833
借酒劲吻你
借酒劲吻你 2021-02-08 19:53

I am 2-days old in the world of Golang, and going through the go tour. I couldn\'t help but notice a peculiarity which I cannot seem to be able to come at terms with a

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-08 20:28

    The method set for a pointer type includes the value receiver methods, but the method set for a value does not include the pointer receiver methods. The method set for a value type does not include the pointer receiver methods because values stored in an interface are not addressable.

提交回复
热议问题