From 7862dace6b82b00333322e0c0ad4277accaa6840 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Mon, 1 Sep 2014 14:15:29 +0800 Subject: [PATCH] Don't panic if can't get address --- scope.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scope.go b/scope.go index 3420c6fb..b0e48662 100644 --- a/scope.go +++ b/scope.go @@ -342,9 +342,11 @@ func (scope *Scope) fieldFromStruct(fieldStruct reflect.StructField) []*Field { field.IsNormal = true } else if embedded := settings["EMBEDDED"]; strings.ToUpper(embedded) == "EMBEDDED" || (embedded == "" && fieldStruct.Anonymous) { var fields []*Field - for _, field := range scope.New(field.Field.Addr().Interface()).Fields() { - field.DBName = field.DBName - fields = append(fields, field) + if field.Field.CanAddr() { + for _, field := range scope.New(field.Field.Addr().Interface()).Fields() { + field.DBName = field.DBName + fields = append(fields, field) + } } return fields } else {