type I interface{}
type II interface{
f1()
}
func g2(a II) {
fmt.Println("xxx")
}
func h3(b I) {
g2(b.(II))
}
type Message struct {
Name string `json:"msg_name"`
}
func (*Message) f1() {
}
func main(){
var m = Message{
Name: "Alice",
}
h3(&m)
}
h3
函数中的g2(b.(II))
这到底是个什么用法?接口强制转换?不像啊,我知道b
其实是从I接口
动态转过来的*Message
类型,那这个b.(II)
算啥意思?