refactor: replace sort.Strings with slices.Sort (#23457)

The slices package provides type-safe generic replacements for the
old typed sort convenience functions. The codebase already uses
slices.Sort in 43 call sites; this finishes the migration for the
remaining 29.

- sort.Strings(x)          -> slices.Sort(x)
- sort.Float64s(x)         -> slices.Sort(x)
- sort.StringsAreSorted(x) -> slices.IsSorted(x)
This commit is contained in:
Mathias Fredriksson
2026-03-23 23:19:23 +02:00
committed by GitHub
parent 9e4c283370
commit 147df5c971
22 changed files with 45 additions and 47 deletions
+1 -2
View File
@@ -3,7 +3,6 @@ package rbac
import (
"fmt"
"slices"
"sort"
"strings"
"github.com/google/uuid"
@@ -176,7 +175,7 @@ func CompositeScopeNames() []string {
for k := range compositePerms {
out = append(out, string(k))
}
sort.Strings(out)
slices.Sort(out)
return out
}
+2 -2
View File
@@ -1,7 +1,7 @@
package rbac
import (
"sort"
"slices"
"strings"
"testing"
@@ -16,7 +16,7 @@ func TestExternalScopeNames(t *testing.T) {
// Ensure sorted ascending
sorted := append([]string(nil), names...)
sort.Strings(sorted)
slices.Sort(sorted)
require.Equal(t, sorted, names)
// Ensure each entry expands to site-only