فهرست منبع

experimenting with recursive update

reid 2 سال پیش
والد
کامیت
ec23f61875
1فایلهای تغییر یافته به همراه4 افزوده شده و 3 حذف شده
  1. 4 3
      broadcast/broadcast.go

+ 4 - 3
broadcast/broadcast.go

@@ -277,9 +277,9 @@ func recursiveUpdate(dst, src reflect.Value) error {
 			if srcVal.Kind() == reflect.Interface {
 				srcVal = srcVal.Elem()
 			}
-			if err := recursiveUpdate(dstField, srcVal); err != nil {
-				return err
-			}
+            if err := recursiveUpdate(dstField.Addr().Elem(), srcVal); err != nil {
+                return err
+            }
 		}
 		return nil
 	}
@@ -291,6 +291,7 @@ func recursiveUpdate(dst, src reflect.Value) error {
 			dstVal := dst.MapIndex(key)
 			if !dstVal.IsValid() {
 				dstVal = reflect.New(dst.Type().Elem()).Elem()
+				dst.SetMapIndex(key, dstVal)
 			}
 			// Recursive call to handle potential nested maps or structs
 			if err := recursiveUpdate(dstVal, srcVal); err != nil {