第一个正确,虽然a和b都是接口的实例,但是因为stu的赋值所以,a和b都可以使用各种方法。
import "fmt"
type Alnterface interface {
Test01()
Test02()
}
type Blnterface interface {
Test01()
Test03()
}
type Stu struct {
}
func (stu Stu) Test01() {}
func (stu Stu) Test02() {}
func (stu Stu) Test03() {}
func main() {
stu := Stu{}
var a Alnterface = stu
var b Blnterface = stu
fmt.Println("ok~", a, b)
}