diff --git a/internal/sort/sorter.go b/internal/sort/sorter.go index e3b9842c..404bc84a 100644 --- a/internal/sort/sorter.go +++ b/internal/sort/sorter.go @@ -1,6 +1,7 @@ package sort import ( + "slices" "sort" "strings" ) @@ -11,9 +12,7 @@ type Sorter func(items []string, namespaces []string) []string // AlphaNumeric sorts the JSON output so that tasks are in alpha numeric order // by task name. func AlphaNumeric(items []string, namespaces []string) []string { - sort.Slice(items, func(i, j int) bool { - return items[i] < items[j] - }) + slices.Sort(items) return items } diff --git a/internal/templater/funcs.go b/internal/templater/funcs.go index 79c837a3..5daabf84 100644 --- a/internal/templater/funcs.go +++ b/internal/templater/funcs.go @@ -1,6 +1,7 @@ package templater import ( + "maps" "path/filepath" "runtime" "strings" @@ -60,13 +61,9 @@ func init() { cap += len(m) } result := make(map[string]any, cap) - for k, v := range base { - result[k] = v - } + maps.Copy(result, base) for _, m := range v { - for k, v := range m { - result[k] = v - } + maps.Copy(result, m) } return result }, @@ -84,7 +81,5 @@ func init() { taskFuncs["ExeExt"] = taskFuncs["exeExt"] templateFuncs = template.FuncMap(sprig.TxtFuncMap()) - for k, v := range taskFuncs { - templateFuncs[k] = v - } + maps.Copy(templateFuncs, taskFuncs) } diff --git a/variables.go b/variables.go index 0b49f50c..c99ea3c1 100644 --- a/variables.go +++ b/variables.go @@ -2,6 +2,7 @@ package task import ( "fmt" + "maps" "os" "path/filepath" "strings" @@ -378,9 +379,7 @@ func product(matrix *ast.Matrix) []map[string]any { for _, item := range row.Value { newComb := make(map[string]any, len(combination)) // Copy the existing combination - for k, v := range combination { - newComb[k] = v - } + maps.Copy(newComb, combination) // Add the current item with the corresponding key newComb[key] = item newResult = append(newResult, newComb)