slices: use strings.EqualFold in ExampleCompactFunc

Change-Id: Ie7d495b2a53520ce89b16bc8a66b81a3955bf32f
Reviewed-on: https://go-review.googlesource.com/c/go/+/530635
Reviewed-by: Eli Bendersky <eliben@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
This commit is contained in:
Ian Lance Taylor 2023-09-22 13:24:37 -07:00 committed by Gopher Robot
parent 9f8f1ca5ad
commit bcfaf2f00f

View File

@ -51,9 +51,7 @@ func ExampleCompact() {
func ExampleCompactFunc() {
names := []string{"bob", "Bob", "alice", "Vera", "VERA"}
names = slices.CompactFunc(names, func(a, b string) bool {
return strings.ToLower(a) == strings.ToLower(b)
})
names = slices.CompactFunc(names, strings.EqualFold)
fmt.Println(names)
// Output:
// [bob alice Vera]