接口声明

  1. type ILearn interface {
  2. }

接口继承

  1. type Humaner interface {
  2. sayhi()
  3. }
  4. type Personer interface {
  5. Humaner // 匿名字段,继承sayhi()
  6. sing()
  7. }
  8. type Student struct {
  9. name string
  10. id int
  11. }
  12. // Student 实现了 sayhi()
  13. func (tmp *Student) sayhi() {
  14. }