From 905b6232a3ccef63fed92bb51f50bd47310328b1 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Mon, 10 Aug 2015 12:40:56 +0800 Subject: [PATCH] Fix can't call callbacks for embedded pointers --- scope.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scope.go b/scope.go index 75b524a0..2af95566 100644 --- a/scope.go +++ b/scope.go @@ -222,10 +222,18 @@ func (scope *Scope) CallMethod(name string, checkError bool) { if values := scope.IndirectValue(); values.Kind() == reflect.Slice { for i := 0; i < values.Len(); i++ { - call(values.Index(i).Addr().Interface()) + value := values.Index(i).Addr().Interface() + if values.Index(i).Kind() == reflect.Ptr { + value = values.Index(i).Interface() + } + call(value) } } else { - call(scope.Value) + if scope.IndirectValue().CanAddr() { + call(scope.IndirectValue().Addr().Interface()) + } else { + call(scope.IndirectValue().Interface()) + } } }