Permalink
Browse files

Fix func comparison to use .Pointer() (to work on Go tip)

Fixes #103
  • Loading branch information...
1 parent 71f93e4 commit f42816ac7eae1340cd3e658e5fa142e543bcc445 @robfig committed Mar 18, 2013
Showing with 3 additions and 3 deletions.
  1. +1 −1 results.go
  2. +2 −2 util.go
View
@@ -303,7 +303,7 @@ func getRedirectUrl(item interface{}) (string, error) {
if typ.Kind() == reflect.Func && typ.NumIn() > 0 {
// Get the Controller Method
recvType := typ.In(0)
- method := FindMethod(recvType, &val)
+ method := FindMethod(recvType, val)
if method == nil {
return "", errors.New("couldn't find method")
}
View
@@ -51,12 +51,12 @@ func ContainsString(list []string, target string) bool {
}
// Return the reflect.Method, given a Receiver type and Func value.
-func FindMethod(recvType reflect.Type, funcVal *reflect.Value) *reflect.Method {
+func FindMethod(recvType reflect.Type, funcVal reflect.Value) *reflect.Method {
// It is not possible to get the name of the method from the Func.
// Instead, compare it to each method of the Controller.
for i := 0; i < recvType.NumMethod(); i++ {
method := recvType.Method(i)
- if method.Func == *funcVal {
+ if method.Func.Pointer() == funcVal.Pointer() {
return &method
}
}

0 comments on commit f42816a

Please sign in to comment.