有一段代码如下:
vc := reflect.New(runrouter.controllerType)
init := vc.MethodByName("Init")
in := make([]reflect.Value, 2)
ct := &Context{ResponseWriter: w, Request: r, Params: params}
in[0] = reflect.ValueOf(ct)
in[1] = reflect.ValueOf(runrouter.controllerType.Name())
init.Call(in)
in = make([]reflect.Value, 0)
method := vc.MethodByName("Prepare")
method.Call(in)
就是在这里调用了Controller
对象的Init(ctx *Context, cn string)
方法
看不懂,求教!
另外请教reflect包下的
type Value struct {
typ *commonType
val unsafe.Pointer
flag
}
到底是些什么东西?
bianweiall 于 2013-03-07 07:48 修改