Skip to content

Commit

Permalink
Update docs gen to use cmp
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinJoiner committed Dec 19, 2023
1 parent 6e4a069 commit b5a9aaf
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions pkg/codegen/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"bufio"
"bytes"
"cmp"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -132,23 +133,12 @@ func getDocFiles(baseDir string) ([]docFile, error) {
slices.SortFunc(docFiles, func(a, b docFile) int {
if a.group == b.group {
if a.resource == b.resource {
return stringCompare(a.version, b.version)
return cmp.Compare(a.version, b.version)
}
return stringCompare(a.resource, b.resource)
return cmp.Compare(a.resource, b.resource)
}
return stringCompare(a.group, b.group)
return cmp.Compare(a.group, b.group)
})

return docFiles, nil
}

// until we can use cmp.Compare from Go 1.21
func stringCompare(a, b string) int {
if a < b {
return -1
} else if a > b {
return 1
} else {
return 0
}
}

0 comments on commit b5a9aaf

Please sign in to comment.