package main

import "fmt"

func main() {
	n := newBs()
	n.Test()
}

type ai interface {
	AI()
}
type as struct {
}

// func (a *as) AI() {
// 	fmt.Println("ai")
// }

type bi interface {
	BI()
}
type bs struct {
}

func (b *bs) BI() {
	fmt.Println("bi")
}

// ns 结构体中有 ai bi接口
// 1、ns 结构体中ai bi 未初始化 选择实现实现接口中的方法 (fun(n *ns)ai bi func)
// 2、ns 结构体中ai bi 初始化 进行实现相对应的接口方法
type ns struct {
	ai
	bi
	Id int64
}
type ni interface {
	ai     // 可以不实现
	bi     // 可以不实现
	Test() // 必须实现
}

func newBs() ni {
	n := &ns{}
	// n.ai = &as{}
	n.bi = &bs{}
	return n
}
// 有人会疑问 这里n.BI(),在 func(n *ns)BI()没有这个方法
// 是因为ns这里查不到,他会去 n.ai.BI() a.bi.BI() 这里查找相对应的方法实现
func (n *ns) Test() {
	// n.AI()
	n.BI()
}

func (n *ns) AI() {
	fmt.Println("ns ai")
}