v0.0.395 MapMerge
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m14s
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m14s
This commit is contained in:
@@ -71,3 +71,19 @@ func ForceMap[K comparable, V any](v map[K]V) map[K]V {
|
||||
return v
|
||||
}
|
||||
}
|
||||
|
||||
func MapMerge[K comparable, V any](base map[K]V, arr ...map[K]V) map[K]V {
|
||||
res := make(map[K]V, len(base)*(1+len(arr)))
|
||||
|
||||
for k, v := range base {
|
||||
res[k] = v
|
||||
}
|
||||
|
||||
for _, m := range arr {
|
||||
for k, v := range m {
|
||||
res[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
Reference in New Issue
Block a user