Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use slices from stdlib over golang.org/x/exp/slices #134

Merged
merged 2 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ require (
github.com/bufbuild/protocompile v0.6.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.4
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1
golang.org/x/sync v0.5.0
google.golang.org/protobuf v1.31.0
gopkg.in/yaml.v3 v3.0.1
Expand Down
2 changes: 0 additions & 2 deletions tools/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc=
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
9 changes: 5 additions & 4 deletions tools/protovalidate-conformance/internal/results/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
package results

import (
"cmp"
"fmt"
"slices"
"strings"

"github.com/bufbuild/protovalidate/tools/internal/gen/buf/validate"
"github.com/bufbuild/protovalidate/tools/internal/gen/buf/validate/conformance/harness"
"golang.org/x/exp/slices"
)

type Result interface {
Expand Down Expand Up @@ -223,10 +224,10 @@ func (u unexpectedErrorResult) IsSuccessWith(_ Result, _ *harness.ResultOptions)
}

func SortViolations(violations []*validate.Violation) {
slices.SortFunc(violations, func(a, b *validate.Violation) bool {
slices.SortFunc(violations, func(a, b *validate.Violation) int {
if a.GetConstraintId() == b.GetConstraintId() {
return a.GetFieldPath() < b.GetFieldPath()
return cmp.Compare(a.GetFieldPath(), b.GetFieldPath())
}
return a.GetConstraintId() < b.GetConstraintId()
return cmp.Compare(a.GetConstraintId(), b.GetConstraintId())
})
}