mirror of
https://github.com/docker/cli.git
synced 2026-09-26 17:30:51 -04:00
templates: modernize with slices and maps packages
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user