Skip to content

Commit

Permalink
revert: don't use cmp.Or as its v1.22 only
Browse files Browse the repository at this point in the history
This reverts commit 8f4a255.
  • Loading branch information
G-Rath committed May 1, 2024
1 parent 8f4a255 commit c4ffa47
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions internal/output/result.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package output

import (
"cmp"
"encoding/json"
"slices"
"strings"
Expand All @@ -24,11 +23,17 @@ func (pss *pkgSourceSet) StableKeys() []pkgWithSource {

slices.SortFunc(pkgWithSrcKeys, func(a, b pkgWithSource) int {
// compare based on each field in descending priority
return cmp.Or(
strings.Compare(a.Source.Path, b.Source.Path),
strings.Compare(a.Package.Name, b.Package.Name),
strings.Compare(a.Package.Version, b.Package.Version),
)
for _, fn := range []func() int{
func() int { return strings.Compare(a.Source.Path, b.Source.Path) },
func() int { return strings.Compare(a.Package.Name, b.Package.Name) },
func() int { return strings.Compare(a.Package.Version, b.Package.Version) },
} {
if r := fn(); r != 0 {
return r
}
}

return 0
})

return pkgWithSrcKeys
Expand Down

0 comments on commit c4ffa47

Please sign in to comment.