diff options
author | 2023-05-29 15:53:55 +0800 | |
---|---|---|
committer | 2023-05-29 09:53:55 +0200 | |
commit | e4be859d48d11e053ed186e45e9598ddcb3497a8 (patch) | |
tree | d7d9a6140a648816b0ef7cafbd9228b5229c4958 /plugin | |
parent | 7231bb0881831fa8eac55b4ea34fc579cba3f43d (diff) | |
download | coredns-e4be859d48d11e053ed186e45e9598ddcb3497a8.tar.gz coredns-e4be859d48d11e053ed186e45e9598ddcb3497a8.tar.zst coredns-e4be859d48d11e053ed186e45e9598ddcb3497a8.zip |
refactor: use standard library instead of `isIn` (#6125)
Signed-off-by: yyzxw <1020938856@qq.com>
Signed-off-by: xiaowu.zhu <xiaowu.zhu@daocloud.io>
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/bind/setup.go | 15 |
1 files 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 -} |