From 27e1d6cdaeef575266f5aa12f33e2e9d0d4938ff Mon Sep 17 00:00:00 2001 From: Dreamacro <8615343+Dreamacro@users.noreply.github.com> Date: Thu, 30 Jun 2022 17:12:06 +0800 Subject: [PATCH] Chore: cleanup code --- adapter/outboundgroup/loadbalance.go | 6 ++---- adapter/outboundgroup/urltest.go | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/adapter/outboundgroup/loadbalance.go b/adapter/outboundgroup/loadbalance.go index 380b0d06b..f396ff044 100644 --- a/adapter/outboundgroup/loadbalance.go +++ b/adapter/outboundgroup/loadbalance.go @@ -30,10 +30,8 @@ type LoadBalance struct { var errStrategy = errors.New("unsupported strategy") func parseStrategy(config map[string]any) string { - if elm, ok := config["strategy"]; ok { - if strategy, ok := elm.(string); ok { - return strategy - } + if strategy, ok := config["strategy"].(string); ok { + return strategy } return "consistent-hashing" } diff --git a/adapter/outboundgroup/urltest.go b/adapter/outboundgroup/urltest.go index 61597498a..fd6d68185 100644 --- a/adapter/outboundgroup/urltest.go +++ b/adapter/outboundgroup/urltest.go @@ -125,10 +125,8 @@ func parseURLTestOption(config map[string]any) []urlTestOption { opts := []urlTestOption{} // tolerance - if elm, ok := config["tolerance"]; ok { - if tolerance, ok := elm.(int); ok { - opts = append(opts, urlTestWithTolerance(uint16(tolerance))) - } + if tolerance, ok := config["tolerance"].(int); ok { + opts = append(opts, urlTestWithTolerance(uint16(tolerance))) } return opts