码迷,mamicode.com
首页 > 其他好文 > 详细

golang里面检测对象是否实现了接口的方法

时间:2014-09-14 20:33:37      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   div   sp   log   on   c   r   

写法有点怪异,记一下吧

_, implemented := this.delegate.(IGenTcpServerDelegate)
if implemented {
    this.delegate.GenTcpServerClientConnected(this.getClientInfoMap(conn))
}

也就是传说中的接口查询,话说go的一些东西真心让人真气逆行啊,哎,就不能设计的人性化点。。。

golang里面检测对象是否实现了接口的方法

标签:style   blog   color   div   sp   log   on   c   r   

原文地址:http://www.cnblogs.com/ziyouchutuwenwu/p/3971438.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!