package main import ( "fmt" "reflect" ) type Peaple struct { } func (p *Peaple) Eat() { } func (p *Peaple) Drink() { } func main() { a := new(Peaple) getType := reflect.TypeOf(a) getValue := reflect.ValueOf(a) fmt.Println(getType) fmt.Println(getValue) obj := reflect.Indirect(getValue).Type().Name() fmt.Println(obj) num := getType.NumMethod() fmt.Println(num) for i := 0; i < num; i++ { m := getType.Method(i) fmt.Println(obj + "." + m.Name) } }
https://blog.csdn.net/raoxiaoya/article/details/109473904