From e4be859d48d11e053ed186e45e9598ddcb3497a8 Mon Sep 17 00:00:00 2001 From: yyzxw <34639446+yyzxw@users.noreply.github.com> Date: Mon, 29 May 2023 15:53:55 +0800 Subject: [PATCH] refactor: use standard library instead of `isIn` (#6125) Signed-off-by: yyzxw <1020938856@qq.com> Signed-off-by: xiaowu.zhu --- plugin/bind/setup.go | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/plugin/bind/setup.go b/plugin/bind/setup.go index 10fe4a955..1bd397585 100644 --- a/plugin/bind/setup.go +++ b/plugin/bind/setup.go @@ -9,6 +9,8 @@ import ( "github.com/coredns/coredns/core/dnsserver" "github.com/coredns/coredns/plugin" "github.com/coredns/coredns/plugin/pkg/log" + + "k8s.io/utils/strings/slices" ) func setup(c *caddy.Controller) error { @@ -37,7 +39,7 @@ func setup(c *caddy.Controller) error { } for _, ip := range ips { - if !isIn(ip, except) { + if !slices.Contains(except, ip) { all = append(all, ip) } } @@ -98,14 +100,3 @@ func listIP(args []string, ifaces []net.Interface) ([]string, error) { } return all, nil } - -// isIn checks if a string array contains an element -func isIn(s string, list []string) bool { - is := false - for _, l := range list { - if s == l { - is = true - } - } - return is -}