diff --git a/backend/utilities/map.go b/backend/utilities/map.go index 756705977..653cc6182 100644 --- a/backend/utilities/map.go +++ b/backend/utilities/map.go @@ -1,11 +1,13 @@ package utilities +// MergeMaps merges multiple maps into a single map. +// The keys of maps earlier in the list will take precedence over keys in later maps. func MergeMaps[K comparable, V any](maps ...map[K]V) map[K]V { merged := make(map[K]V) - for _, m := range maps { - for key, value := range m { - merged[key] = value + for index := len(maps) - 1; index >= 0; index-- { + for k, v := range maps[index] { + merged[k] = v } }