zhyq0826/zhyq0826.github.io

理解 Go interface 的 5 个关键点 | 三月沙

Opened this issue · 1 comments

理解 Go interface 的 5 个关键点 | 三月沙

1、interface 是一种类型1234type I interface { Get() int} 首先 interface 是一种类型,从它的定义可以看出来用了 type 关键字,更准确的说 interface 是一种具有一组方法的类型,这些方法定义了 interface 的行为。 go 允许不带任何方法的 interface ,这种类型的 interface 叫 e

http://sanyuesha.com/2017/07/22/how-to-understand-go-interface/

写的不错