关于go1.7,reflect 的NumMethod,替代方案是什么?

```go package main import ( "fmt" "reflect" ) type Student struct { Name string Age int } func (s *Student) printName() { fmt.Println(s.Name) } func (s *Student) getAge() int { return s.Age } func main() { s := Student{Name: "lcpeng", Age: 25} rt := reflect.TypeOf(s) // 若是指针,则取指针指向元素 if rt.Kind() == reflect.Ptr { rt = rt.Elem() } fmt.Println(rt.PkgPath()) fmt.Println(rt.Name()) fmt.Println(rt.NumField()) fmt.Println(rt.NumMethod()) // 1.7为0 } ``` 查了下1.7的release notes,看到: > The Method and NumMethod methods of Type and Value no longer return or count unexported methods.The Method and NumMethod methods of Type and Value no longer return or count unexported methods. 那1.7版本改怎么获取呢?
已邀请:

songtianyi

赞同来自: lcp0578

export it

要回复问题请先登录注册