package main
import (
"log"
"reflect"
)
type AT interface {
A()
B()
C()
D()
E()
}
type at struct {
}
func (a *at) A(S string) {
log.Println("A")
}
func (a *at) B() {
log.Println("B")
}
func (a *at) C() {
log.Println("C")
}
func (a *at) D() {
log.Println("D")
}
func (a *at) E() {
log.Println("E")
}
func main() {
a := &at{}
typeTest(a)
}
func typeTest(a interface{}) {
value := reflect.ValueOf(a)
typ := reflect.TypeOf(a)
for i := 0; i < typ.NumMethod(); i++ {
methodName := typ.Method(i).Name
// 客户端接口
method := value.MethodByName(methodName)
method.Call([]reflect.Value{reflect.ValueOf("A")})
log.Println(methodName, method)
}
}