go 结构体嵌套interface
package main import "fmt" //结构体嵌套接口,可以在结构体绑定的方法直接实现接口中的方法,直接调用接口中的方法 type aa interface{ a() b() } type world struct{ aa Age int } func(h world)a(){ fmt.Println("hello a方法") } func(h world)b(){ fmt.Println("hello b方法") } func main() { world:=world{} world.b() //输出 hello b方法
}
posted on 2023-07-21 10:04 running-fly 阅读(5) 评论(0) 编辑 收藏 举报