Update field.go (#4228)

seems like the `if-else` branch do the same thing, so remove it
This commit is contained in:
gavwu 2021-04-02 09:56:38 +08:00 committed by GitHub
parent 33601dc72f
commit 8cfa9d98f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 9 deletions

View File

@ -441,15 +441,8 @@ func (field *Field) setupValuerAndSetter() {
// ReflectValueOf // ReflectValueOf
switch { switch {
case len(field.StructField.Index) == 1: case len(field.StructField.Index) == 1:
if field.FieldType.Kind() == reflect.Ptr { field.ReflectValueOf = func(value reflect.Value) reflect.Value {
field.ReflectValueOf = func(value reflect.Value) reflect.Value { return reflect.Indirect(value).Field(field.StructField.Index[0])
fieldValue := reflect.Indirect(value).Field(field.StructField.Index[0])
return fieldValue
}
} else {
field.ReflectValueOf = func(value reflect.Value) reflect.Value {
return reflect.Indirect(value).Field(field.StructField.Index[0])
}
} }
case len(field.StructField.Index) == 2 && field.StructField.Index[0] >= 0 && field.FieldType.Kind() != reflect.Ptr: case len(field.StructField.Index) == 2 && field.StructField.Index[0] >= 0 && field.FieldType.Kind() != reflect.Ptr:
field.ReflectValueOf = func(value reflect.Value) reflect.Value { field.ReflectValueOf = func(value reflect.Value) reflect.Value {