From da90b999d2cda6df6cea1c2da11a94fac0ef0c20 Mon Sep 17 00:00:00 2001 From: garrettladley Date: Sat, 18 May 2024 12:34:58 -0400 Subject: [PATCH] update utilities.MergeMaps --- backend/utilities/map.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 } }