go interface

1 接口定义:

type iface_name interface{

  //....

}

 

2 接口实现

// 非空接口

type iface struct {

  tab     *itab

  data    unsafe.Pointer  // data *int

}

// 空接口

type iface struct {

  _type  *_type

  data    unsafe.Pointer  // data *int

}

type _type struct {

  size          uintptr

  hash        uint32

  _unused   uint8

  align         uint8

  fieldalign   uint8

  kind         uint8

      alg           unsafe.Pointer

      gc           [2]uintptr

      _string     *string

      x            *uncommontype

      ptrto       *_type

      zero        *byte

}

 

 

参考:

http://www.cnblogs.com/concurrency/p/4311958.html

 

posted @ 2015-05-14 13:36  ~逍遥~  阅读(232)  评论(0编辑  收藏  举报