Don't panic if can't get address

This commit is contained in:
Jinzhu 2014-09-01 14:15:29 +08:00
parent 204356b320
commit 7862dace6b
1 changed files with 5 additions and 3 deletions

View File

@ -342,9 +342,11 @@ func (scope *Scope) fieldFromStruct(fieldStruct reflect.StructField) []*Field {
field.IsNormal = true field.IsNormal = true
} else if embedded := settings["EMBEDDED"]; strings.ToUpper(embedded) == "EMBEDDED" || (embedded == "" && fieldStruct.Anonymous) { } else if embedded := settings["EMBEDDED"]; strings.ToUpper(embedded) == "EMBEDDED" || (embedded == "" && fieldStruct.Anonymous) {
var fields []*Field var fields []*Field
for _, field := range scope.New(field.Field.Addr().Interface()).Fields() { if field.Field.CanAddr() {
field.DBName = field.DBName for _, field := range scope.New(field.Field.Addr().Interface()).Fields() {
fields = append(fields, field) field.DBName = field.DBName
fields = append(fields, field)
}
} }
return fields return fields
} else { } else {