mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08: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:
@@ -9,6 +9,7 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
"regexp"
|
||||
"slices"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
@@ -168,7 +169,7 @@ func writeDocs(sections [][]byte) error {
|
||||
if mdFiles[j].title == "General" {
|
||||
return false // ... < "General" - not sorted
|
||||
}
|
||||
return sort.StringsAreSorted([]string{mdFiles[i].title, mdFiles[j].title})
|
||||
return slices.IsSorted([]string{mdFiles[i].title, mdFiles[j].title})
|
||||
})
|
||||
|
||||
// Update manifest.json
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"regexp"
|
||||
"sort"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/xerrors"
|
||||
@@ -37,7 +37,7 @@ func main() {
|
||||
missing = append(missing, k)
|
||||
}
|
||||
}
|
||||
sort.Strings(missing)
|
||||
slices.Sort(missing)
|
||||
|
||||
if len(missing) == 0 {
|
||||
_, _ = fmt.Println("check-scopes: OK — all RBAC <resource>:<action> values exist in api_key_scope enum")
|
||||
|
||||
@@ -3,7 +3,7 @@ package main
|
||||
import (
|
||||
"errors"
|
||||
"os/exec"
|
||||
"sort"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -180,7 +180,7 @@ func ghBuildPRMetadataMap(commits []commitEntry) (*prMetadataMaps, error) {
|
||||
var labels []string
|
||||
if parts[3] != "" {
|
||||
labels = strings.Split(parts[3], ",")
|
||||
sort.Strings(labels)
|
||||
slices.Sort(labels)
|
||||
}
|
||||
meta := prMetadata{
|
||||
Labels: labels,
|
||||
|
||||
Reference in New Issue
Block a user