From c707a4b2e02bc4ece59716944b87d9ff7b428b40 Mon Sep 17 00:00:00 2001
From: LaurenceLiZhixin <382673304@qq.com>
Date: Thu, 18 Mar 2021 20:26:45 +0800
Subject: [PATCH] fix: linter

---
 cluster/directory/base_directory.go    | 36 --------------------------
 cluster/router/uniform/router_chain.go |  2 +-
 cluster/router/uniform/uniform_rule.go |  3 ++-
 registry/directory/directory.go        | 10 +++----
 remoting/k8sCRD/client.go              |  2 +-
 5 files changed, 9 insertions(+), 44 deletions(-)

diff --git a/cluster/directory/base_directory.go b/cluster/directory/base_directory.go
index c21367758..3a6a337db 100644
--- a/cluster/directory/base_directory.go
+++ b/cluster/directory/base_directory.go
@@ -72,42 +72,6 @@ func (dir *BaseDirectory) GetDirectoryUrl() *common.URL {
 	return dir.url
 }
 
-// SetRouters Convert url to routers and add them into dir.routerChain
-func (dir *BaseDirectory) SetRouters(urls []*common.URL) {
-	//if len(urls) == 0 {
-	//	return
-	//}
-	//
-	//routers := make([]router.PriorityRouter, 0, len(urls))
-	//
-	//rc := dir.routerChain
-	//
-	//for _, url := range urls {
-	//	routerKey := url.GetParam(constant.ROUTER_KEY, "")
-	//
-	//	if len(routerKey) == 0 {
-	//		continue
-	//	}
-	//	if url.Protocol == constant.CONDITION_ROUTE_PROTOCOL {
-	//		if !dir.isProperRouter(url) {
-	//			continue
-	//		}
-	//	}
-	//	factory := extension.GetRouterFactory(url.Protocol)
-	//	r, err := factory.NewPriorityRouter(url, rc.GetNotifyChan())
-	//	if err != nil {
-	//		logger.Errorf("Create router fail. router key: %s, url:%s, error: %+v", routerKey, url.Service(), err)
-	//		return
-	//	}
-	//	routers = append(routers, r)
-	//}
-	//
-	//logger.Infof("Init file condition router success, size: %v", len(routers))
-	//dir.mutex.Lock()
-	//rc.AddRouters(routers)
-	//dir.mutex.Unlock()
-}
-
 func (dir *BaseDirectory) isProperRouter(url *common.URL) bool {
 	app := url.GetParam(constant.APPLICATION_KEY, "")
 	dirApp := dir.GetUrl().GetParam(constant.APPLICATION_KEY, "")
diff --git a/cluster/router/uniform/router_chain.go b/cluster/router/uniform/router_chain.go
index 436fb0e36..09d3e10d0 100644
--- a/cluster/router/uniform/router_chain.go
+++ b/cluster/router/uniform/router_chain.go
@@ -153,7 +153,7 @@ func (r *RouterChain) Process(event *config_center.ConfigChangeEvent) {
 	}
 
 	if event.ConfigType == remoting.EventTypeDel {
-
+		// todo delete router
 	}
 }
 
diff --git a/cluster/router/uniform/uniform_rule.go b/cluster/router/uniform/uniform_rule.go
index 5d2e15f78..e11d29c1c 100644
--- a/cluster/router/uniform/uniform_rule.go
+++ b/cluster/router/uniform/uniform_rule.go
@@ -183,6 +183,7 @@ func newUniformRule(dubboRoute *config.DubboRoute, destinationMap map[string]map
 func (u *UniformRule) route(invokers []protocol.Invoker, url *common.URL, invocation protocol.Invocation) []protocol.Invoker {
 	// service rule + destination -> filter
 	resultInvokers := make([]protocol.Invoker, 0)
+	var err error
 	matchService := false
 	for _, v := range u.services {
 		// check if match service field
@@ -200,7 +201,7 @@ func (u *UniformRule) route(invokers []protocol.Invoker, url *common.URL, invoca
 	for _, rule := range u.virtualServiceRules {
 		if rule.match(url, invocation) {
 			// match this rule, do get target logic
-			resultInvokers, err := rule.getRuleTargetInvokers(invokers)
+			resultInvokers, err = rule.getRuleTargetInvokers(invokers)
 			if err != nil {
 				logger.Error("getRuleTargetInvokers from rule err = ", err)
 				return nil
diff --git a/registry/directory/directory.go b/registry/directory/directory.go
index aace9cc94..8ef6f9150 100644
--- a/registry/directory/directory.go
+++ b/registry/directory/directory.go
@@ -256,11 +256,11 @@ func (dir *RegistryDirectory) cacheInvokerByEvent(event *registry.ServiceEvent)
 
 // configRouters configures dynamic routers into the router chain, but, the current impl is incorrect, see FIXME above.
 func (dir *RegistryDirectory) configRouters() {
-	var urls []*common.URL
-	for _, v := range config.GetRouterURLSet().Values() {
-		urls = append(urls, v.(*common.URL))
-	}
-
+	//var urls []*common.URL
+	//for _, v := range config.GetRouterURLSet().Values() {
+	//	urls = append(urls, v.(*common.URL))
+	//}
+	//
 	//if len(urls) > 0 {
 	//	dir.SetRouters(urls)
 	//}
diff --git a/remoting/k8sCRD/client.go b/remoting/k8sCRD/client.go
index 4b3c1a1e0..87fdd8cd8 100644
--- a/remoting/k8sCRD/client.go
+++ b/remoting/k8sCRD/client.go
@@ -63,7 +63,7 @@ func NewK8sCRDClient(groupName, groupVersion, namespace string, handlers ...List
 	SchemeBuilder := runtime.NewSchemeBuilder(newClient.addKnownTypes)
 
 	// add to scheme
-	if err := SchemeBuilder.AddToScheme(scheme.Scheme); err != nil {
+	if err = SchemeBuilder.AddToScheme(scheme.Scheme); err != nil {
 		logger.Error("AddToScheme failed in k8s CRD process")
 		return nil, err
 	}
-- 
GitLab