nil lookup fix
This commit is contained in:
parent
09b3faa8da
commit
03b83d3fb9
12
lookup.go
12
lookup.go
@ -156,10 +156,14 @@ func Lookup(db *mgo.Database, structField string, results interface{}, selector
|
||||
object := objectIDs[objectID]
|
||||
|
||||
field := elV.FieldByName(structField)
|
||||
if fieldIsPtr {
|
||||
field.Set(reflect.ValueOf(object))
|
||||
} else {
|
||||
field.Set(reflect.ValueOf(object).Elem())
|
||||
if object != nil && field.CanSet() {
|
||||
objectVal := reflect.ValueOf(object)
|
||||
|
||||
if fieldIsPtr {
|
||||
field.Set(objectVal)
|
||||
} else {
|
||||
field.Set(objectVal.Elem())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user