@@ -20,6 +20,7 @@ import (
2020 "errors"
2121 "fmt"
2222 "reflect"
23+ "slices"
2324 "sort"
2425 "strconv"
2526 "strings"
@@ -495,7 +496,7 @@ func checkError(expected, actual *conformancev1.Error, otherCodes []conformancev
495496 }
496497
497498 var errs multiErrors
498- if expected .Code != actual .Code && ! inSlice ( actual .Code , otherCodes ) {
499+ if expected .Code != actual .Code && ! slices . Contains ( otherCodes , actual .Code ) {
499500 expectedCodes := expectedCodeString (expected .Code , otherCodes )
500501 errs = append (errs , fmt .Errorf ("actual error {code: %d (%s), message: %q} does not match expected code %s" ,
501502 actual .Code , connect .Code (actual .Code ).String (), actual .GetMessage (), expectedCodes ))
@@ -556,17 +557,6 @@ func indent(s string) string {
556557 return strings .Join (lines , "\n " )
557558}
558559
559- func inSlice [T comparable ](elem T , slice []T ) bool {
560- // TODO: delete this function when this repo is using Go 1.21
561- // and update call sites to instead use slices.Contains
562- for _ , item := range slice {
563- if item == elem {
564- return true
565- }
566- }
567- return false
568- }
569-
570560func expectedCodeString (expectedCode conformancev1.Code , otherAllowedCodes []conformancev1.Code ) string {
571561 allowedCodes := make ([]string , len (otherAllowedCodes )+ 1 )
572562 for i , code := range append ([]conformancev1.Code {expectedCode }, otherAllowedCodes ... ) {
0 commit comments