mirror of
https://github.com/89luca89/distrobox.git
synced 2026-08-19 01:14:49 -05:00
refactor(config): use maps.Copy in mergeConfigMaps
Replace the hand-rolled nested-loop map merge with the stdlib maps.Copy. Rename the variadic parameter to configMaps so it no longer shadows the maps package. Signed-off-by: Luca Di Maio <luca.dimaio1@gmail.com>
This commit is contained in:
@@ -2,6 +2,7 @@ package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"maps"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -151,12 +152,10 @@ func getConfigFilePaths() ([]string, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func mergeConfigMaps(maps ...map[string]string) map[string]string {
|
||||
func mergeConfigMaps(configMaps ...map[string]string) map[string]string {
|
||||
merged := make(map[string]string)
|
||||
for _, m := range maps {
|
||||
for k, v := range m {
|
||||
merged[k] = v
|
||||
}
|
||||
for _, m := range configMaps {
|
||||
maps.Copy(merged, m)
|
||||
}
|
||||
return merged
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user