Getting the union of two maps in go -
i have recursive function creates objects representing file paths (the keys paths , values info file). it's recursive it's meant handle files, if directory encountered, function recursively called on directory.
all being said, i'd equivalent of set union on 2 maps (i.e. "main" map updated values recursive call). there idiomatic way aside iterating on 1 map , assigning each key, value in same thing in other map?
that is: given a,b of type map [string] *someobject, , a , b populated, there way update a values in b?
there no built in way, nor method in standard packages such merge.
the idomatic way iterate:
for k, v := range b { a[k] = v }
Comments
Post a Comment