package main import ( "fmt" "reflect" ) type Person struct{} func (p *Person) Run() { fmt.Println("person running") } func doit(object interface{}, method interface{}) { v := reflect.ValueOf(object) f := reflect.ValueOf(method) f.Call([]reflect.Value{v}) } func main() { p := new(Person) doit(p, (*Person).Run) }
有疑问加站长微信联系(非本文作者)
![](https://static.golangjob.cn/static/img/footer.png?imageView2/2/w/280)