feat: migrate to golang

This commit is contained in:
2026-07-19 20:01:38 +08:00
parent 302d4e6bb5
commit a2630df9e0
69 changed files with 4750 additions and 3369 deletions

27
internal/corecfg/merge.go Normal file
View File

@ -0,0 +1,27 @@
package corecfg
// deepMerge merges dict2 into dict1 in place and returns dict1, mirroring
// corecfg_manager.py's module-level deep_merge(): nested maps recurse,
// matching lists are concatenated, everything else is overwritten by dict2.
func deepMerge(dict1, dict2 map[string]interface{}) map[string]interface{} {
for k, v := range dict2 {
existing, exists := dict1[k]
if exists {
existingMap, existingIsMap := existing.(map[string]interface{})
vMap, vIsMap := v.(map[string]interface{})
if existingIsMap && vIsMap {
dict1[k] = deepMerge(existingMap, vMap)
continue
}
existingList, existingIsList := existing.([]interface{})
vList, vIsList := v.([]interface{})
if existingIsList && vIsList {
dict1[k] = append(existingList, vList...)
continue
}
}
dict1[k] = v
}
return dict1
}