fix config nil error
This commit is contained in:
@@ -37,22 +37,23 @@ func In(value interface{}, container interface{}) bool {
|
||||
}
|
||||
|
||||
func Override(left interface{}, right interface{}) {
|
||||
if left == nil || right == nil {
|
||||
if reflect.ValueOf(left).IsNil() || reflect.ValueOf(right).IsNil() {
|
||||
return
|
||||
}
|
||||
|
||||
if reflect.ValueOf(left).Type().Kind() != reflect.Ptr ||
|
||||
reflect.ValueOf(right).Type().Kind() != reflect.Ptr {
|
||||
reflect.ValueOf(right).Type().Kind() != reflect.Ptr ||
|
||||
reflect.ValueOf(left).Kind() != reflect.ValueOf(right).Kind() {
|
||||
return
|
||||
}
|
||||
|
||||
old := reflect.ValueOf(left).Elem()
|
||||
new := reflect.ValueOf(right).Elem()
|
||||
oldVal := reflect.ValueOf(left).Elem()
|
||||
newVal := reflect.ValueOf(right).Elem()
|
||||
|
||||
for i := 0; i < old.NumField(); i++ {
|
||||
val := new.Field(i).Interface()
|
||||
for i := 0; i < oldVal.NumField(); i++ {
|
||||
val := newVal.Field(i).Interface()
|
||||
if !reflect.DeepEqual(val, reflect.Zero(reflect.TypeOf(val)).Interface()) {
|
||||
old.Field(i).Set(reflect.ValueOf(val))
|
||||
oldVal.Field(i).Set(reflect.ValueOf(val))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user