小智 6

interface
interface
var x interface{}  // x is nil and has static type interface{}
var v *T           // v has value nil, static type *T
x = 42             // x has value 42 and dynamic type int
x = v              // x has value (*T)(nil) and dynamic type *T

和:

接口类型:

接口类型指定称为其接口的方法集.接口类型的变量可以使用方法集存储任何类型的值,该方法集是接口的任何超集.据说这种类型实现了接口.接口类型的未初始化变量的值为nil.

  • 说go不是OOP语言是不准确的.它具有对象(任何用户定义的类型)和方法,而不是继承.但继承不是面向对象语言的定义属性 - 请参阅https://en.wikipedia.org/wiki/Object-oriented_programming (3认同)
  • ACK.我总是说Go是面向对象的,但不是基于类的. (2认同)