From 414c42afe0ee8856b708b62c78bb122cd8ec3b33 Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Wed, 6 Dec 2023 10:37:40 -0800 Subject: [PATCH] tag: fix build On tip (the Go 1.22 code freeze), Go reports that `compareTag` has the wrong method signature: ``` type func(a Tag, b Tag) int of tagCompare does not match inferred type func(a Tag, b Tag) bool for func(a E, b E) bool ``` Fix this by using the correct method signature. --- go.mod | 2 +- go.sum | 6 ++---- tag.go | 12 +++--------- tag_test.go | 2 +- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/go.mod b/go.mod index 42051cd..7627566 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/segmentio/objconv v1.0.1 github.com/segmentio/vpcinfo v0.1.10 github.com/stretchr/testify v1.8.4 - golang.org/x/exp v0.0.0-20230905200255-921286631fa9 + golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb golang.org/x/sync v0.3.0 ) diff --git a/go.sum b/go.sum index 6246565..b0ff1c1 100644 --- a/go.sum +++ b/go.sum @@ -15,8 +15,6 @@ github.com/mdlayher/taskstats v0.0.0-20190313225729-7cbba52ee072 h1:7YEPiUVGht4Z github.com/mdlayher/taskstats v0.0.0-20190313225729-7cbba52ee072/go.mod h1:sGdS7A6CAETR53zkdjGkgoFlh1vSm7MtX+i8XfEsTMA= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/segmentio/fasthash v0.0.0-20180216231524-a72b379d632e h1:uO75wNGioszjmIzcY/tvdDYKRLVvzggtAmmJkn9j4GQ= -github.com/segmentio/fasthash v0.0.0-20180216231524-a72b379d632e/go.mod h1:tm/wZFQ8e24NYaBGIlnO2WGCAi67re4HHuOm0sftE/M= github.com/segmentio/fasthash v1.0.3 h1:EI9+KE1EwvMLBWwjpRDc+fEM+prwxDYbslddQGtrmhM= github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY= github.com/segmentio/objconv v1.0.1 h1:QjfLzwriJj40JibCV3MGSEiAoXixbp4ybhwfTB8RXOM= @@ -26,8 +24,8 @@ github.com/segmentio/vpcinfo v0.1.10/go.mod h1:KEIWiWRE/KLh90mOzOY0QkFWT7ObUYLp9 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/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= -golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= +golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= +golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= diff --git a/tag.go b/tag.go index 645f47a..94dfa42 100644 --- a/tag.go +++ b/tag.go @@ -51,15 +51,9 @@ func SortTags(tags []Tag) []Tag { return deduplicateTags(tags) } -func tagCompare(a, b Tag) int { - switch { - case a.Name < b.Name: - return -1 - case a.Name > b.Name: - return +1 - } - - return 0 +// reports whether a is less than b +func tagCompare(a, b Tag) bool { + return a.Name < b.Name } func deduplicateTags(tags []Tag) []Tag { diff --git a/tag_test.go b/tag_test.go index e06154b..1d86745 100644 --- a/tag_test.go +++ b/tag_test.go @@ -190,7 +190,7 @@ func BenchmarkTagsOrder(b *testing.B) { func tagIsLessByIndex(tags []Tag) func(int, int) bool { return func(i, j int) bool { - return tagCompare(tags[i], tags[j]) < 0 + return tagCompare(tags[i], tags[j]) == false } }