支持对直接声明的结构体指针反射填充数据
支持类似这样的操作: func userByID(id int)(user *User,err error){ err = db.Find(&user,id).Error return }
This commit is contained in:
parent
5b8c0dd6b9
commit
de4d189fb7
3
utils.go
3
utils.go
@ -130,6 +130,9 @@ func Expr(expression string, args ...interface{}) *expr {
|
||||
|
||||
func indirect(reflectValue reflect.Value) reflect.Value {
|
||||
for reflectValue.Kind() == reflect.Ptr {
|
||||
if reflectValue.IsNil() && reflectValue.CanSet() {
|
||||
reflectValue.Set(reflect.New(reflectValue.Type().Elem()))
|
||||
}
|
||||
reflectValue = reflectValue.Elem()
|
||||
}
|
||||
return reflectValue
|
||||
|
Loading…
x
Reference in New Issue
Block a user