v0.0.395 MapMerge
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m14s

This commit is contained in:
2024-02-27 13:42:06 +01:00
parent 8edc067a3b
commit 10c3780b52
4 changed files with 24 additions and 4 deletions

View File

@@ -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
}