refactor: use slices.Equal to simplify code

Signed-off-by: MarkDaveny <peicuiping@aliyun.com>
This commit is contained in:
MarkDaveny 2025-03-08 19:28:05 +08:00 committed by Ayoub Mrini
parent 7a7bc65237
commit 53be282396

View File

@ -23,6 +23,7 @@ import (
"net/http/httptest" "net/http/httptest"
"net/url" "net/url"
"os" "os"
"slices"
"sort" "sort"
"strconv" "strconv"
"sync" "sync"
@ -1156,12 +1157,7 @@ func requireTargets(
} }
sort.Strings(expectedTargets) sort.Strings(expectedTargets)
sort.Strings(sTargets) sort.Strings(sTargets)
for i, t := range sTargets { return slices.Equal(sTargets, expectedTargets)
if t != expectedTargets[i] {
return false
}
}
return true
}, 1*time.Second, 100*time.Millisecond) }, 1*time.Second, 100*time.Millisecond)
} }