Re: [go-nuts] How to get struct of function

2016-07-29 Thread Peter Waller
Try this: https://play.golang.org/p/zJa8N24nxi -- package main import ( "fmt" "log" "reflect" ) func main() { var controller interface{} = Test.IsWorking funcTyp := reflect.TypeOf(controller) structTyp := funcTyp.In(0) newValue := reflect.New(structTyp).Interface() fmt.Printf("%#+v", newValue)

[go-nuts] How to get struct of function

2016-07-26 Thread nakotoffana
Lets say an example function like this func (r *Router) Get(path string, controller interface{}) {} And I am calling it this way Route.Get("/", controllers.Test.IsWorking) Refering to this function type Test struct { Name string } func (t Test) IsWorking() { log.Println("hello") } How c