map.go 376 B

1234567891011121314151617
  1. package utils
  2. func MergeMaps(destMap, sourceMap map[string]interface{}) map[string]interface{} {
  3. newMap := make(map[string]interface{})
  4. // 将目标 map 的元素复制到新 map 中
  5. for key, value := range destMap {
  6. newMap[key] = value
  7. }
  8. // 将源 map 中的元素合并到新 map 中
  9. for key, value := range sourceMap {
  10. newMap[key] = value
  11. }
  12. return newMap
  13. }