github.com/argoproj/argo-cd/v3@v3.2.1/util/collections/maps.go (about) 1 package collections 2 3 import "maps" 4 5 // Merge takes a collection of maps and returns a single map, where by items are merged of all given sets. 6 // If any keys overlap, Then the last specified key takes precedence. 7 // Example: 8 // 9 // data := collections.Merge(map[string]string{"foo": "bar1", "baz": "bar1"}, map[string]string{"foo": "bar2"}) // returns: map[string]string{"foo": "bar2", "empty": "bar1"} 10 func Merge[K comparable, V any](items ...map[K]V) map[K]V { 11 res := make(map[K]V) 12 for _, m := range items { 13 maps.Copy(res, m) 14 } 15 return res 16 }