From 684d1ed98d3378cb57993e5822cb1fcfda8721ef Mon Sep 17 00:00:00 2001 From: devopsbo3 <69951731+devopsbo3@users.noreply.github.com> Date: Fri, 10 Nov 2023 12:27:53 -0600 Subject: [PATCH] Revert "build: use slices package for sorting (#27486)" This reverts commit 3ecc4c4b2dea541bd55eaca26be6c6323964c06a. --- build/update-license.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/build/update-license.go b/build/update-license.go index 52a54bf66a..f61536470a 100644 --- a/build/update-license.go +++ b/build/update-license.go @@ -46,13 +46,12 @@ import ( "path/filepath" "regexp" "runtime" + "sort" "strconv" "strings" "sync" "text/template" "time" - - "golang.org/x/exp/slices" ) var ( @@ -153,6 +152,13 @@ func (i info) gpl() bool { return false } +// authors implements the sort.Interface for strings in case-insensitive mode. +type authors []string + +func (as authors) Len() int { return len(as) } +func (as authors) Less(i, j int) bool { return strings.ToLower(as[i]) < strings.ToLower(as[j]) } +func (as authors) Swap(i, j int) { as[i], as[j] = as[j], as[i] } + func main() { var ( files = getFiles() @@ -293,9 +299,7 @@ func writeAuthors(files []string) { } } // Write sorted list of authors back to the file. - slices.SortFunc(list, func(a, b string) bool { - return strings.ToLower(a) < strings.ToLower(b) - }) + sort.Sort(authors(list)) content := new(bytes.Buffer) content.WriteString(authorsFileHeader) for _, a := range list {