package main
import (
"fmt"
"reflect"
)
type Cal struct {
Num1, num2 int
}
func (cal Cal) GetSub(name string) {
fmt.Printf("%v 完成了减法运行,%v - %v = %v", name, cal.Num1, cal.num2, cal.Num1-cal.num2)
}
func rt(v interface{}) {
rv:=reflect.ValueOf(v)
num := rv.NumField()
for i := 0; i < num; i++ {
fmt.Println(rv.Field(i),rv.Field(i).Kind())
}
in := append([]reflect.Value{},reflect.ValueOf("tom"))
rv.Method(0).Call(in)
}
func main() {
var x = Cal{8,5}
rt(x)
}