mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
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:
committed by
GitHub
parent
9e4c283370
commit
147df5c971
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user