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

写法有点怪异,记一下吧

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

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

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