字典合并

数组和集合 / 字典

import (
    "fmt"
    "maps"
)

var d1 = map[int]string{1: "one"}
var d2 = map[int]string{2: "two", 3: "three"}

var dAll = map[int]string{}
maps.Insert(dAll, maps.All(d1))
maps.Insert(dAll, maps.All(d2))
//dAll is map[1:one 2:two 3:three]

fmt.Println("dAll is", dAll)