diff --git a/cue/build/import.go b/cue/build/import.go index 71ae48496..86d90a3cf 100644 --- a/cue/build/import.go +++ b/cue/build/import.go @@ -15,7 +15,7 @@ package build import ( - "sort" + "slices" "strconv" "cuelang.org/go/cue/errors" @@ -78,7 +78,7 @@ func (inst *Instance) complete() errors.Error { } } - sort.Strings(paths) + slices.Sort(paths) if inst.loadFunc != nil { for i, path := range paths { @@ -147,7 +147,7 @@ func (inst *Instance) complete() errors.Error { for dep := range deps { inst.Deps = append(inst.Deps, dep) } - sort.Strings(inst.Deps) + slices.Sort(inst.Deps) for _, dep := range inst.Deps { p1 := deps[dep] diff --git a/cue/load/instances.go b/cue/load/instances.go index 84aa43b24..748854903 100644 --- a/cue/load/instances.go +++ b/cue/load/instances.go @@ -18,7 +18,7 @@ import ( "context" "fmt" "io/fs" - "sort" + "slices" "strconv" "strings" @@ -218,7 +218,7 @@ func loadPackages( for p := range pkgPaths { pkgPathSlice = append(pkgPathSlice, p) } - sort.Strings(pkgPathSlice) + slices.Sort(pkgPathSlice) return modpkgload.LoadPackages( ctx, cfg.Module, diff --git a/cue/load/loader_common.go b/cue/load/loader_common.go index 677aed37b..37af722f9 100644 --- a/cue/load/loader_common.go +++ b/cue/load/loader_common.go @@ -19,7 +19,6 @@ import ( pathpkg "path" "path/filepath" "slices" - "sort" "strconv" "strings" @@ -350,7 +349,7 @@ func cleanImports(m map[string][]token.Pos) ([]string, map[string][]token.Pos) { for path := range m { all = append(all, path) } - sort.Strings(all) + slices.Sort(all) return all, m } diff --git a/encoding/jsonschema/external_test.go b/encoding/jsonschema/external_test.go index 128d9ff3c..cc2e66c29 100644 --- a/encoding/jsonschema/external_test.go +++ b/encoding/jsonschema/external_test.go @@ -20,7 +20,7 @@ import ( "io" "os" "path" - "sort" + "slices" "strings" "testing" @@ -259,7 +259,7 @@ func sortedKeys[T any](m map[string]T) []string { for k := range m { ks = append(ks, k) } - sort.Strings(ks) + slices.Sort(ks) return ks } diff --git a/encoding/jsonschema/teststats.go b/encoding/jsonschema/teststats.go index 26f098040..aadc5b6bc 100644 --- a/encoding/jsonschema/teststats.go +++ b/encoding/jsonschema/teststats.go @@ -24,7 +24,7 @@ import ( "log" "os" "path" - "sort" + "slices" "cuelang.org/go/cue/token" "cuelang.org/go/encoding/jsonschema/internal/externaltest" @@ -85,6 +85,6 @@ func sortedKeys[T any](m map[string]T) []string { for k := range m { ks = append(ks, k) } - sort.Strings(ks) + slices.Sort(ks) return ks } diff --git a/encoding/openapi/build.go b/encoding/openapi/build.go index c35846282..7cb06fb76 100644 --- a/encoding/openapi/build.go +++ b/encoding/openapi/build.go @@ -19,6 +19,7 @@ import ( "math" "path" "regexp" + "slices" "sort" "strings" @@ -152,7 +153,7 @@ func schemas(g *Generator, inst cue.InstanceOrValue) (schemas *ast.StructLit, er for k := range c.externalRefs { external = append(external, k) } - sort.Strings(external) + slices.Sort(external) for _, k := range external { ext := c.externalRefs[k] diff --git a/internal/core/adt/eval_test.go b/internal/core/adt/eval_test.go index b8444f4d8..56981fb5b 100644 --- a/internal/core/adt/eval_test.go +++ b/internal/core/adt/eval_test.go @@ -18,7 +18,7 @@ import ( "flag" "fmt" "path/filepath" - "sort" + "slices" "strings" "testing" @@ -198,7 +198,7 @@ func runEvalTest(t *cuetxtar.Test, version internal.EvaluatorVersion, flags cued keys[i] = k i++ } - sort.Strings(keys) + slices.Sort(keys) for _, s := range keys { t.Errorf(" -- path: %s", s) } diff --git a/internal/mod/modimports/modimports.go b/internal/mod/modimports/modimports.go index d8be606bc..2f7640ca1 100644 --- a/internal/mod/modimports/modimports.go +++ b/internal/mod/modimports/modimports.go @@ -5,7 +5,7 @@ import ( "fmt" "io/fs" "path" - "sort" + "slices" "strconv" "strings" @@ -60,7 +60,7 @@ func AllImports(modFilesIter func(func(ModuleFile, error) bool)) (_ []string, re for p := range pkgPaths { pkgPathSlice = append(pkgPathSlice, p) } - sort.Strings(pkgPathSlice) + slices.Sort(pkgPathSlice) return pkgPathSlice, nil } diff --git a/internal/mod/modpkgload/pkgload.go b/internal/mod/modpkgload/pkgload.go index 51598edbc..15d936035 100644 --- a/internal/mod/modpkgload/pkgload.go +++ b/internal/mod/modpkgload/pkgload.go @@ -6,7 +6,6 @@ import ( "io/fs" "runtime" "slices" - "sort" "strings" "sync/atomic" @@ -315,7 +314,7 @@ func (pkgs *Packages) load(ctx context.Context, pkg *Package) { for imp := range importsMap { imports = append(imports, imp) } - sort.Strings(imports) // Make the algorithm deterministic for tests. + slices.Sort(imports) // Make the algorithm deterministic for tests. pkg.imports = make([]*Package, 0, len(imports)) var importFlags Flags diff --git a/internal/vcs/git.go b/internal/vcs/git.go index d27a561cd..925613acb 100644 --- a/internal/vcs/git.go +++ b/internal/vcs/git.go @@ -18,7 +18,7 @@ import ( "context" "fmt" "path/filepath" - "sort" + "slices" "strconv" "strings" "time" @@ -72,7 +72,7 @@ func (v gitVCS) ListFiles(ctx context.Context, dir string, paths ...string) ([]s return nil, nil } files := strings.Split(out, "\x00") - sort.Strings(files) + slices.Sort(files) return files, nil } diff --git a/pkg/list/sort.go b/pkg/list/sort.go index 3f5d99f64..6c5e5310c 100644 --- a/pkg/list/sort.go +++ b/pkg/list/sort.go @@ -19,6 +19,7 @@ package list import ( + "slices" "sort" "cuelang.org/go/cue" @@ -212,7 +213,7 @@ func SortStable(list []cue.Value, cmp cue.Value) (sorted []cue.Value, err error) // SortStrings sorts a list of strings in increasing order. func SortStrings(a []string) []string { - sort.Strings(a) + slices.Sort(a) return a } @@ -226,5 +227,5 @@ func IsSorted(list []cue.Value, cmp cue.Value) bool { // IsSortedStrings tests whether a list is a sorted lists of strings. func IsSortedStrings(a []string) bool { - return sort.StringsAreSorted(a) + return slices.IsSorted(a) }