templates: modernize with slices and maps packages

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2026-09-02 02:50:27 +02:00
parent 33d586d81f
commit 6ea81b3e2e
+3 -3
View File
@@ -8,7 +8,7 @@ import (
"encoding/json"
"fmt"
"reflect"
"sort"
"slices"
"strings"
"text/template"
)
@@ -125,12 +125,12 @@ func joinElements(elems any, sep string) (string, error) {
return b.String(), nil
case reflect.Map:
var out []string
out := make([]string, 0, rv.Len())
for _, k := range rv.MapKeys() {
out = append(out, fmt.Sprint(rv.MapIndex(k).Interface()))
}
// Not ideal, but trying to keep a consistent order
sort.Strings(out)
slices.Sort(out)
return strings.Join(out, sep), nil
default: