From 668e085d89f9cd5253670f864e6492fc2749c68e Mon Sep 17 00:00:00 2001
From: AlexStocks <alexstocks@foxmail.com>
Date: Mon, 28 Dec 2020 14:49:42 +0800
Subject: [PATCH] fix errors by linter

---
 cluster/loadbalance/random_test.go                    |  3 +++
 cluster/router/chain/chain.go                         |  3 +++
 cluster/router/condition/file_test.go                 |  3 +++
 cluster/router/condition/router.go                    | 11 +++++++++--
 cluster/router/condition/router_test.go               |  2 ++
 .../router/healthcheck/default_health_check_test.go   |  3 +++
 common/constant/key.go                                |  8 +++++---
 common/proxy/proxy.go                                 |  6 +-----
 common/rpc_service.go                                 |  4 ++--
 common/rpc_service_test.go                            |  5 ++++-
 common/yaml/yaml_test.go                              |  2 +-
 config/service_config.go                              |  2 +-
 config_center/apollo/impl_test.go                     |  6 +++---
 config_center/file/impl.go                            |  2 +-
 config_center/file/impl_test.go                       |  4 ++++
 config_center/nacos/impl_test.go                      |  2 ++
 config_center/nacos/listener.go                       |  9 +++++----
 config_center/zookeeper/impl_test.go                  |  3 +++
 filter/access_key.go                                  |  2 +-
 filter/filter_impl/access_log_filter_test.go          |  2 +-
 filter/filter_impl/active_filter_test.go              |  2 +-
 filter/filter_impl/auth/default_authenticator.go      |  2 +-
 filter/filter_impl/auth/default_authenticator_test.go |  9 +++++----
 filter/filter_impl/execute_limit_filter.go            |  2 +-
 filter/filter_impl/generic_service_filter_test.go     |  4 ++--
 filter/filter_impl/graceful_shutdown_filter_test.go   |  3 ++-
 .../tps/tps_limit_sliding_window_strategy.go          |  2 +-
 metadata/service/remote/service.go                    |  4 +++-
 protocol/dubbo/dubbo_codec.go                         |  3 +--
 protocol/dubbo/hessian2/hessian_dubbo_test.go         |  2 ++
 protocol/rest/server/rest_server.go                   |  2 ++
 registry/base_registry.go                             |  4 ++++
 registry/consul/registry.go                           |  2 +-
 registry/consul/service_discovery.go                  |  9 ++-------
 registry/kubernetes/registry_test.go                  |  2 +-
 remoting/etcdv3/client_test.go                        |  4 ++--
 remoting/getty/dubbo_codec_for_test.go                |  3 +--
 remoting/getty/getty_client.go                        |  2 +-
 remoting/getty/getty_server.go                        |  2 +-
 remoting/getty/listener_test.go                       |  2 +-
 remoting/kubernetes/client.go                         |  6 +++---
 remoting/kubernetes/client_test.go                    |  6 +++---
 remoting/kubernetes/registry_controller.go            |  2 +-
 remoting/nacos/builder_test.go                        |  2 ++
 44 files changed, 101 insertions(+), 62 deletions(-)

diff --git a/cluster/loadbalance/random_test.go b/cluster/loadbalance/random_test.go
index b94d7da43..c24fdf055 100644
--- a/cluster/loadbalance/random_test.go
+++ b/cluster/loadbalance/random_test.go
@@ -83,6 +83,7 @@ func TestRandomlbSelectWeight(t *testing.T) {
 		}
 		selectedInvoker = append(selectedInvoker, s)
 	}
+	assert.Equal(t, 10000, len(selectedInvoker))
 
 	assert.Condition(t, func() bool {
 		// really is 0.9999999999999
@@ -114,6 +115,8 @@ func TestRandomlbSelectWarmup(t *testing.T) {
 		}
 		selectedInvoker = append(selectedInvoker, s)
 	}
+	assert.Equal(t, 10000, len(selectedInvoker))
+
 	assert.Condition(t, func() bool {
 		return selected/10000 < 0.1
 	})
diff --git a/cluster/router/chain/chain.go b/cluster/router/chain/chain.go
index 8c4ffe01b..8b98acb58 100644
--- a/cluster/router/chain/chain.go
+++ b/cluster/router/chain/chain.go
@@ -195,6 +195,9 @@ func (c *RouterChain) copyInvokerIfNecessary(cache *InvokerCache) []protocol.Inv
 func (c *RouterChain) buildCache() {
 	origin := c.loadCache()
 	invokers := c.copyInvokerIfNecessary(origin)
+	if invokers == nil || len(invokers) == 0 {
+		return
+	}
 
 	var (
 		mutex sync.Mutex
diff --git a/cluster/router/condition/file_test.go b/cluster/router/condition/file_test.go
index bd19a0d18..d609c7dce 100644
--- a/cluster/router/condition/file_test.go
+++ b/cluster/router/condition/file_test.go
@@ -116,6 +116,9 @@ func TestParseServiceRouterKey(t *testing.T) {
 
 	testString = "grp:mock-service:123"
 	grp, srv, ver, err = parseServiceRouterKey(testString)
+	assert.Equal(t, "", grp)
+	assert.Equal(t, "", srv)
+	assert.Equal(t, "", ver)
 	assert.Error(t, err)
 
 	testString = ""
diff --git a/cluster/router/condition/router.go b/cluster/router/condition/router.go
index 2fc33072d..0817b3284 100644
--- a/cluster/router/condition/router.go
+++ b/cluster/router/condition/router.go
@@ -46,6 +46,13 @@ var (
 	routerPatternReg = regexp.MustCompile(`([&!=,]*)\s*([^&!=,\s]+)`)
 )
 
+var (
+	emptyMatchPair = MatchPair{
+		Matches:    gxset.NewSet(),
+		Mismatches: gxset.NewSet(),
+	}
+)
+
 // ConditionRouter Condition router struct
 type ConditionRouter struct {
 	Pattern       string
@@ -221,14 +228,14 @@ func parseRule(rule string) (map[string]MatchPair, error) {
 				condition[content] = pair
 			}
 		case "=":
-			if &pair == nil {
+			if pair == emptyMatchPair {
 				var startIndex = getStartIndex(rule)
 				return nil, perrors.Errorf("Illegal route rule \"%s\", The error char '%s' at index %d before \"%d\".", rule, separator, startIndex, startIndex)
 			}
 			values = pair.Matches
 			values.Add(content)
 		case "!=":
-			if &pair == nil {
+			if pair == emptyMatchPair {
 				var startIndex = getStartIndex(rule)
 				return nil, perrors.Errorf("Illegal route rule \"%s\", The error char '%s' at index %d before \"%d\".", rule, separator, startIndex, startIndex)
 			}
diff --git a/cluster/router/condition/router_test.go b/cluster/router/condition/router_test.go
index 3d33ca275..a344b64ef 100644
--- a/cluster/router/condition/router_test.go
+++ b/cluster/router/condition/router_test.go
@@ -70,10 +70,12 @@ func TestNewConditionRouter(t *testing.T) {
 	assert.EqualValues(t, router.ThenCondition, thenRule)
 
 	router, err = NewConditionRouter(nil)
+	assert.Nil(t, router)
 	assert.Error(t, err)
 
 	url, _ = common.NewURL(`condition://0.0.0.0:?application=mock-app&category=routers&force=true&priority=1&router=condition&rule=YSAmT4gYiAmIGQ%3D`)
 	router, err = NewConditionRouter(url)
+	assert.Nil(t, router)
 	assert.Error(t, err)
 
 	url, _ = common.NewURL(`condition://0.0.0.0:?application=mock-app&category=routers&force=true&router=condition&rule=YSAmIGMgPT4gYiAmIGQ%3D`)
diff --git a/cluster/router/healthcheck/default_health_check_test.go b/cluster/router/healthcheck/default_health_check_test.go
index 39827c5f0..c32a60788 100644
--- a/cluster/router/healthcheck/default_health_check_test.go
+++ b/cluster/router/healthcheck/default_health_check_test.go
@@ -56,6 +56,7 @@ func TestDefaultHealthCheckerIsHealthy(t *testing.T) {
 	}
 	hc = NewDefaultHealthChecker(url).(*DefaultHealthChecker)
 	healthy = hc.IsHealthy(invoker)
+	assert.False(t, false, healthy)
 	// the outgoing request is more than OUTSTANDING_REQUEST_COUNT_LIMIT, go to unhealthy
 	assert.False(t, hc.IsHealthy(invoker))
 
@@ -67,11 +68,13 @@ func TestDefaultHealthCheckerIsHealthy(t *testing.T) {
 	url.SetParam(constant.OUTSTANDING_REQUEST_COUNT_LIMIT_KEY, "1000")
 	hc = NewDefaultHealthChecker(url).(*DefaultHealthChecker)
 	healthy = hc.IsHealthy(invoker)
+	assert.False(t, false, healthy)
 	assert.False(t, hc.IsHealthy(invoker))
 
 	// reset successive failed count and go to healthy
 	request(url, healthCheckMethodTest, 0, false, true)
 	healthy = hc.IsHealthy(invoker)
+	assert.False(t, false, healthy)
 	assert.True(t, hc.IsHealthy(invoker))
 }
 
diff --git a/common/constant/key.go b/common/constant/key.go
index c256659ac..d020b9d40 100644
--- a/common/constant/key.go
+++ b/common/constant/key.go
@@ -201,6 +201,8 @@ const (
 	TRACING_REMOTE_SPAN_CTX = "tracing.remote.span.ctx"
 )
 
+type AttachmentCtxKey string
+
 // Use for router module
 const (
 	// ConditionRouterName Specify file condition router name
@@ -238,7 +240,7 @@ const (
 	Tagkey      = "dubbo.tag"
 
 	// Attachment key in context in invoker
-	AttachmentKey = "attachment"
+	AttachmentKey = AttachmentCtxKey("attachment")
 )
 
 const (
@@ -265,7 +267,7 @@ const (
 	// signature format
 	SIGNATURE_STRING_FORMAT = "%s#%s#%s#%s"
 	// key whether enable signature
-	PARAMTER_SIGNATURE_ENABLE_KEY = "param.sign"
+	PARAMETER_SIGNATURE_ENABLE_KEY = "param.sign"
 	// consumer
 	CONSUMER = "consumer"
 	// key of access key id
@@ -293,7 +295,7 @@ const (
 	HEALTH_CHECKER = "health.checker"
 	// The name of the default implementation of HealthChecker
 	DEFAULT_HEALTH_CHECKER = "default"
-	// The key of oustanding-request-limit
+	// The key of outstanding-request-limit
 	OUTSTANDING_REQUEST_COUNT_LIMIT_KEY = "outstanding.request.limit"
 	// The key of successive-failed-request's threshold
 	SUCCESSIVE_FAILED_REQUEST_THRESHOLD_KEY = "successive.failed.threshold"
diff --git a/common/proxy/proxy.go b/common/proxy/proxy.go
index 3a0194170..55f533cb2 100644
--- a/common/proxy/proxy.go
+++ b/common/proxy/proxy.go
@@ -158,15 +158,11 @@ func (p *Proxy) Implement(v common.RPCService) {
 			}
 
 			result := p.invoke.Invoke(invCtx, inv)
-			if len(result.Attachments()) > 0 {
-				invCtx = context.WithValue(invCtx, constant.AttachmentKey, result.Attachments())
-			}
-
 			err = result.Error()
 			if err != nil {
 				// the cause reason
 				err = perrors.Cause(err)
-				// if some error happened, it should be log some info in the seperate file.
+				// if some error happened, it should be log some info in the separate file.
 				if throwabler, ok := err.(java_exception.Throwabler); ok {
 					logger.Warnf("invoke service throw exception: %v , stackTraceElements: %v", err.Error(), throwabler.GetStackTrace())
 				} else {
diff --git a/common/rpc_service.go b/common/rpc_service.go
index 572fc7170..9f587f3a6 100644
--- a/common/rpc_service.go
+++ b/common/rpc_service.go
@@ -156,13 +156,13 @@ type serviceMap struct {
 	interfaceMap map[string][]*Service          // interface -> service
 }
 
-// GetService gets a service defination by protocol and name
+// GetService gets a service definition by protocol and name
 func (sm *serviceMap) GetService(protocol, interfaceName, group, version string) *Service {
 	serviceKey := ServiceKey(interfaceName, group, version)
 	return sm.GetServiceByServiceKey(protocol, serviceKey)
 }
 
-// GetService gets a service defination by protocol and service key
+// GetService gets a service definition by protocol and service key
 func (sm *serviceMap) GetServiceByServiceKey(protocol, serviceKey string) *Service {
 	sm.mutex.RLock()
 	defer sm.mutex.RUnlock()
diff --git a/common/rpc_service_test.go b/common/rpc_service_test.go
index b50d8d962..048e623c6 100644
--- a/common/rpc_service_test.go
+++ b/common/rpc_service_test.go
@@ -132,7 +132,10 @@ func TestServiceMapUnRegister(t *testing.T) {
 
 func TestMethodTypeSuiteContext(t *testing.T) {
 	mt := &MethodType{ctxType: reflect.TypeOf(context.TODO())}
-	ctx := context.WithValue(context.Background(), "key", "value")
+	ctx := context.Background()
+	type ctxKey string
+	key := ctxKey("key")
+	ctx = context.WithValue(ctx, key, "value")
 	assert.Equal(t, reflect.ValueOf(ctx), mt.SuiteContext(ctx))
 
 	assert.Equal(t, reflect.Zero(mt.ctxType), mt.SuiteContext(nil))
diff --git a/common/yaml/yaml_test.go b/common/yaml/yaml_test.go
index 5a271a258..19f4fe148 100644
--- a/common/yaml/yaml_test.go
+++ b/common/yaml/yaml_test.go
@@ -66,5 +66,5 @@ type Config struct {
 }
 
 type ChildConfig struct {
-	StrTest string `default:"strTest" default:"default" yaml:"strTest"  json:"strTest,omitempty"`
+	StrTest string `default:"default" yaml:"strTest"  json:"strTest,omitempty"`
 }
diff --git a/config/service_config.go b/config/service_config.go
index 087f537b5..8bc1b91ee 100644
--- a/config/service_config.go
+++ b/config/service_config.go
@@ -312,7 +312,7 @@ func (c *ServiceConfig) getUrlMap() url.Values {
 
 	// auth filter
 	urlMap.Set(constant.SERVICE_AUTH_KEY, c.Auth)
-	urlMap.Set(constant.PARAMTER_SIGNATURE_ENABLE_KEY, c.ParamSign)
+	urlMap.Set(constant.PARAMETER_SIGNATURE_ENABLE_KEY, c.ParamSign)
 
 	// whether to export or not
 	urlMap.Set(constant.EXPORT_KEY, strconv.FormatBool(c.export))
diff --git a/config_center/apollo/impl_test.go b/config_center/apollo/impl_test.go
index 4720775c2..404457022 100644
--- a/config_center/apollo/impl_test.go
+++ b/config_center/apollo/impl_test.go
@@ -126,17 +126,17 @@ func initApollo() *httptest.Server {
 }
 
 func configResponse(rw http.ResponseWriter, _ *http.Request) {
-	result := fmt.Sprintf(mockConfigRes)
+	result := mockConfigRes
 	fmt.Fprintf(rw, "%s", result)
 }
 
 func notifyResponse(rw http.ResponseWriter, req *http.Request) {
-	result := fmt.Sprintf(mockNotifyRes)
+	result := mockNotifyRes
 	fmt.Fprintf(rw, "%s", result)
 }
 
 func serviceConfigResponse(rw http.ResponseWriter, _ *http.Request) {
-	result := fmt.Sprintf(mockServiceConfigRes)
+	result := mockServiceConfigRes
 	fmt.Fprintf(rw, "%s", result)
 }
 
diff --git a/config_center/file/impl.go b/config_center/file/impl.go
index f29a33d5e..9afe7c652 100644
--- a/config_center/file/impl.go
+++ b/config_center/file/impl.go
@@ -180,7 +180,7 @@ func (fsdc *FileSystemDynamicConfiguration) GetConfigKeysByGroup(group string) (
 	return r, nil
 }
 
-// RemoveConfig will remove the config whit hte (key, group)
+// RemoveConfig will remove tconfig_center/nacos/impl_testhe config whit hte (key, group)
 func (fsdc *FileSystemDynamicConfiguration) RemoveConfig(key string, group string) error {
 	tmpPath := fsdc.GetPath(key, group)
 	_, err := fsdc.deleteDelay(tmpPath)
diff --git a/config_center/file/impl_test.go b/config_center/file/impl_test.go
index e912cb707..556b6a3d7 100644
--- a/config_center/file/impl_test.go
+++ b/config_center/file/impl_test.go
@@ -63,6 +63,7 @@ func TestPublishAndGetConfig(t *testing.T) {
 
 func TestAddListener(t *testing.T) {
 	file, err := initFileData(t)
+	assert.Nil(t, err)
 	group := "dubbogo"
 	value := "Test Value"
 	err = file.PublishConfig(key, group, value)
@@ -81,6 +82,7 @@ func TestAddListener(t *testing.T) {
 
 func TestRemoveListener(t *testing.T) {
 	file, err := initFileData(t)
+	assert.NoError(t, err)
 	group := "dubbogo"
 	value := "Test Value"
 	err = file.PublishConfig(key, group, value)
@@ -106,9 +108,11 @@ func TestRemoveListener(t *testing.T) {
 
 func TestGetConfigKeysByGroup(t *testing.T) {
 	file, err := initFileData(t)
+	assert.Nil(t, err)
 	group := "dubbogo"
 	value := "Test Value"
 	err = file.PublishConfig(key, group, value)
+	assert.NoError(t, err)
 	gs, err := file.GetConfigKeysByGroup(group)
 	assert.NoError(t, err)
 	assert.Equal(t, 1, gs.Size())
diff --git a/config_center/nacos/impl_test.go b/config_center/nacos/impl_test.go
index 40efa5f4f..710fef09d 100644
--- a/config_center/nacos/impl_test.go
+++ b/config_center/nacos/impl_test.go
@@ -85,6 +85,8 @@ func TestGetConfig(t *testing.T) {
 	nacos, err := initNacosData(t)
 	assert.NoError(t, err)
 	configs, err := nacos.GetProperties("dubbo.properties", config_center.WithGroup("dubbo"))
+	assert.Empty(t, configs)
+	assert.NoError(t, err)
 	_, err = nacos.Parser().Parse(configs)
 	assert.NoError(t, err)
 }
diff --git a/config_center/nacos/listener.go b/config_center/nacos/listener.go
index 57df0363a..b0607e29b 100644
--- a/config_center/nacos/listener.go
+++ b/config_center/nacos/listener.go
@@ -38,7 +38,6 @@ func callback(listener config_center.ConfigurationListener, _, _, dataId, data s
 func (n *nacosDynamicConfiguration) addListener(key string, listener config_center.ConfigurationListener) {
 	_, loaded := n.keyListeners.Load(key)
 	if !loaded {
-		_, cancel := context.WithCancel(context.Background())
 		err := (*n.client.Client()).ListenConfig(vo.ConfigParam{
 			DataId: key,
 			Group:  "dubbo",
@@ -50,13 +49,15 @@ func (n *nacosDynamicConfiguration) addListener(key string, listener config_cent
 			logger.Errorf("nacos : listen config fail, error:%v ", err)
 			return
 		}
+		_, cancel := context.WithCancel(context.Background())
 		newListener := make(map[config_center.ConfigurationListener]context.CancelFunc)
 		newListener[listener] = cancel
 		n.keyListeners.Store(key, newListener)
-	} else {
-		// TODO check goroutine alive, but this version of go_nacos_sdk is not support.
-		logger.Infof("profile:%s. this profile is already listening", key)
+		return
 	}
+
+	// TODO check goroutine alive, but this version of go_nacos_sdk is not support.
+	logger.Infof("profile:%s. this profile is already listening", key)
 }
 
 func (n *nacosDynamicConfiguration) removeListener(key string, listener config_center.ConfigurationListener) {
diff --git a/config_center/zookeeper/impl_test.go b/config_center/zookeeper/impl_test.go
index d4a9de41f..808bf8fd5 100644
--- a/config_center/zookeeper/impl_test.go
+++ b/config_center/zookeeper/impl_test.go
@@ -107,10 +107,13 @@ func TestGetConfig(t *testing.T) {
 	assert.Equal(t, "5s", m["dubbo.consumer.request_timeout"])
 	configs, err = reg.GetProperties(dubboPropertyFileName)
 	assert.Error(t, err)
+	assert.Equal(t, "", configs)
 	configs, err = reg.GetInternalProperty(dubboPropertyFileName)
 	assert.Error(t, err)
+	assert.Equal(t, "", configs)
 	configs, err = reg.GetRule(dubboPropertyFileName)
 	assert.Error(t, err)
+	assert.Equal(t, "", configs)
 }
 
 func TestAddListener(t *testing.T) {
diff --git a/filter/access_key.go b/filter/access_key.go
index 4801d64fe..f38764bce 100644
--- a/filter/access_key.go
+++ b/filter/access_key.go
@@ -26,7 +26,7 @@ import (
 type AccessKeyPair struct {
 	AccessKey    string `yaml:"accessKey"   json:"accessKey,omitempty" property:"accessKey"`
 	SecretKey    string `yaml:"secretKey"   json:"secretKey,omitempty" property:"secretKey"`
-	ConsumerSide string `yaml:"consumerSide"   json:"ConsumerSide,consumerSide" property:"consumerSide"`
+	ConsumerSide string `yaml:"consumerSide"   json:"consumerSide,omitempty" property:"consumerSide"`
 	ProviderSide string `yaml:"providerSide"   json:"providerSide,omitempty" property:"providerSide"`
 	Creator      string `yaml:"creator"   json:"creator,omitempty" property:"creator"`
 	Options      string `yaml:"options"   json:"options,omitempty" property:"options"`
diff --git a/filter/filter_impl/access_log_filter_test.go b/filter/filter_impl/access_log_filter_test.go
index a3a6151aa..9c4b947db 100644
--- a/filter/filter_impl/access_log_filter_test.go
+++ b/filter/filter_impl/access_log_filter_test.go
@@ -77,6 +77,6 @@ func TestAccessLogFilterInvokeDefaultConfig(t *testing.T) {
 func TestAccessLogFilterOnResponse(t *testing.T) {
 	result := &protocol.RPCResult{}
 	accessLogFilter := GetAccessLogFilter()
-	response := accessLogFilter.OnResponse(nil, result, nil, nil)
+	response := accessLogFilter.OnResponse(context.TODO(), result, nil, nil)
 	assert.Equal(t, result, response)
 }
diff --git a/filter/filter_impl/active_filter_test.go b/filter/filter_impl/active_filter_test.go
index 9837a49c7..9f024fec3 100644
--- a/filter/filter_impl/active_filter_test.go
+++ b/filter/filter_impl/active_filter_test.go
@@ -65,7 +65,7 @@ func TestActiveFilterOnResponse(t *testing.T) {
 	result := &protocol.RPCResult{
 		Err: errors.New("test"),
 	}
-	filter.OnResponse(nil, result, invoker, invoc)
+	filter.OnResponse(context.TODO(), result, invoker, invoc)
 	methodStatus := protocol.GetMethodStatus(url, "test")
 	urlStatus := protocol.GetURLStatus(url)
 
diff --git a/filter/filter_impl/auth/default_authenticator.go b/filter/filter_impl/auth/default_authenticator.go
index 5b86fc148..7c7131c9c 100644
--- a/filter/filter_impl/auth/default_authenticator.go
+++ b/filter/filter_impl/auth/default_authenticator.go
@@ -69,7 +69,7 @@ func getSignature(url *common.URL, invocation protocol.Invocation, secrectKey st
 	requestString := fmt.Sprintf(constant.SIGNATURE_STRING_FORMAT,
 		url.ColonSeparatedKey(), invocation.MethodName(), secrectKey, currentTime)
 	var signature string
-	if parameterEncrypt := url.GetParamBool(constant.PARAMTER_SIGNATURE_ENABLE_KEY, false); parameterEncrypt {
+	if parameterEncrypt := url.GetParamBool(constant.PARAMETER_SIGNATURE_ENABLE_KEY, false); parameterEncrypt {
 		var err error
 		if signature, err = SignWithParams(invocation.Arguments(), requestString, secrectKey); err != nil {
 			// TODO
diff --git a/filter/filter_impl/auth/default_authenticator_test.go b/filter/filter_impl/auth/default_authenticator_test.go
index 37c7e9d18..d915b6a16 100644
--- a/filter/filter_impl/auth/default_authenticator_test.go
+++ b/filter/filter_impl/auth/default_authenticator_test.go
@@ -39,7 +39,7 @@ func TestDefaultAuthenticator_Authenticate(t *testing.T) {
 	secret := "dubbo-sk"
 	access := "dubbo-ak"
 	testurl, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider?interface=com.ikurento.user.UserProvider&group=gg&version=2.6.0")
-	testurl.SetParam(constant.PARAMTER_SIGNATURE_ENABLE_KEY, "true")
+	testurl.SetParam(constant.PARAMETER_SIGNATURE_ENABLE_KEY, "true")
 	testurl.SetParam(constant.ACCESS_KEY_ID_KEY, access)
 	testurl.SetParam(constant.SECRET_ACCESS_KEY_KEY, secret)
 	parmas := []interface{}{"OK", struct {
@@ -77,7 +77,7 @@ func TestDefaultAuthenticator_Sign(t *testing.T) {
 	testurl, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider?application=test&interface=com.ikurento.user.UserProvider&group=gg&version=2.6.0")
 	testurl.SetParam(constant.ACCESS_KEY_ID_KEY, "akey")
 	testurl.SetParam(constant.SECRET_ACCESS_KEY_KEY, "skey")
-	testurl.SetParam(constant.PARAMTER_SIGNATURE_ENABLE_KEY, "false")
+	testurl.SetParam(constant.PARAMETER_SIGNATURE_ENABLE_KEY, "false")
 	inv := invocation.NewRPCInvocation("test", []interface{}{"OK"}, nil)
 	_ = authenticator.Sign(inv, testurl)
 	assert.NotEqual(t, inv.AttachmentsByKey(constant.REQUEST_SIGNATURE_KEY, ""), "")
@@ -113,12 +113,13 @@ func Test_getAccessKeyPairFailed(t *testing.T) {
 		common.WithParamsValue(constant.SECRET_ACCESS_KEY_KEY, "skey"),
 		common.WithParamsValue(constant.ACCESS_KEY_ID_KEY, "akey"), common.WithParamsValue(constant.ACCESS_KEY_STORAGE_KEY, "dubbo"))
 	_, e = getAccessKeyPair(invcation, testurl)
+	assert.NoError(t, e)
 
 }
 
 func Test_getSignatureWithinParams(t *testing.T) {
 	testurl, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider?interface=com.ikurento.user.UserProvider&group=gg&version=2.6.0")
-	testurl.SetParam(constant.PARAMTER_SIGNATURE_ENABLE_KEY, "true")
+	testurl.SetParam(constant.PARAMETER_SIGNATURE_ENABLE_KEY, "true")
 	inv := invocation.NewRPCInvocation("test", []interface{}{"OK"}, map[string]interface{}{
 		"": "",
 	})
@@ -134,7 +135,7 @@ func Test_getSignatureWithinParams(t *testing.T) {
 
 func Test_getSignature(t *testing.T) {
 	testurl, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider?interface=com.ikurento.user.UserProvider&group=gg&version=2.6.0")
-	testurl.SetParam(constant.PARAMTER_SIGNATURE_ENABLE_KEY, "false")
+	testurl.SetParam(constant.PARAMETER_SIGNATURE_ENABLE_KEY, "false")
 	inv := invocation.NewRPCInvocation("test", []interface{}{"OK"}, nil)
 	secret := "dubbo"
 	current := strconv.Itoa(int(time.Now().Unix() * 1000))
diff --git a/filter/filter_impl/execute_limit_filter.go b/filter/filter_impl/execute_limit_filter.go
index 5fc309cfb..35611611c 100644
--- a/filter/filter_impl/execute_limit_filter.go
+++ b/filter/filter_impl/execute_limit_filter.go
@@ -84,7 +84,7 @@ func (ef *ExecuteLimitFilter) Invoke(ctx context.Context, invoker protocol.Invok
 	methodConfigPrefix := "methods." + invocation.MethodName() + "."
 	ivkURL := invoker.GetUrl()
 	limitTarget := ivkURL.ServiceKey()
-	limitRateConfig := constant.DEFAULT_EXECUTE_LIMIT
+	var limitRateConfig string
 
 	methodLevelConfig := ivkURL.GetParam(methodConfigPrefix+constant.EXECUTE_LIMIT_KEY, "")
 	if len(methodLevelConfig) > 0 {
diff --git a/filter/filter_impl/generic_service_filter_test.go b/filter/filter_impl/generic_service_filter_test.go
index 8b2fb549c..c755a2d28 100644
--- a/filter/filter_impl/generic_service_filter_test.go
+++ b/filter/filter_impl/generic_service_filter_test.go
@@ -125,7 +125,7 @@ func TestGenericServiceFilterResponseTestStruct(t *testing.T) {
 	filter := GetGenericServiceFilter()
 	methodName := "$invoke"
 	rpcInvocation := invocation.NewRPCInvocation(methodName, aurguments, nil)
-	r := filter.OnResponse(nil, result, nil, rpcInvocation)
+	r := filter.OnResponse(context.TODO(), result, nil, rpcInvocation)
 	assert.NotNil(t, r.Result())
 	assert.Equal(t, reflect.ValueOf(r.Result()).Kind(), reflect.Map)
 }
@@ -143,7 +143,7 @@ func TestGenericServiceFilterResponseString(t *testing.T) {
 	filter := GetGenericServiceFilter()
 	methodName := "$invoke"
 	rpcInvocation := invocation.NewRPCInvocation(methodName, aurguments, nil)
-	r := filter.OnResponse(nil, result, nil, rpcInvocation)
+	r := filter.OnResponse(context.TODO(), result, nil, rpcInvocation)
 	assert.NotNil(t, r.Result())
 	assert.Equal(t, reflect.ValueOf(r.Result()).Kind(), reflect.String)
 }
diff --git a/filter/filter_impl/graceful_shutdown_filter_test.go b/filter/filter_impl/graceful_shutdown_filter_test.go
index 447a557ad..c2c1ef874 100644
--- a/filter/filter_impl/graceful_shutdown_filter_test.go
+++ b/filter/filter_impl/graceful_shutdown_filter_test.go
@@ -65,7 +65,8 @@ func TestGenericFilterInvoke(t *testing.T) {
 	shutdownFilter.shutdownConfig = providerConfig.ShutdownConfig
 
 	assert.True(t, shutdownFilter.rejectNewRequest())
-	result = shutdownFilter.OnResponse(nil, nil, protocol.NewBaseInvoker(invokeUrl), invoc)
+	result = shutdownFilter.OnResponse(context.Background(), nil, protocol.NewBaseInvoker(invokeUrl), invoc)
+	assert.Nil(t, result)
 
 	rejectHandler := &common2.OnlyLogRejectedExecutionHandler{}
 	extension.SetRejectedExecutionHandler("mock", func() filter.RejectedExecutionHandler {
diff --git a/filter/filter_impl/tps/tps_limit_sliding_window_strategy.go b/filter/filter_impl/tps/tps_limit_sliding_window_strategy.go
index cbbba19ff..bc78f6471 100644
--- a/filter/filter_impl/tps/tps_limit_sliding_window_strategy.go
+++ b/filter/filter_impl/tps/tps_limit_sliding_window_strategy.go
@@ -54,7 +54,7 @@ type SlidingWindowTpsLimitStrategyImpl struct {
 	queue    *list.List
 }
 
-// IsAllowable determins whether the number of requests within the time window overs the threshold
+// IsAllowable determines whether the number of requests within the time window overs the threshold
 // It is thread-safe.
 func (impl *SlidingWindowTpsLimitStrategyImpl) IsAllowable() bool {
 	impl.mutex.Lock()
diff --git a/metadata/service/remote/service.go b/metadata/service/remote/service.go
index efd16bdc6..ae1c344d2 100644
--- a/metadata/service/remote/service.go
+++ b/metadata/service/remote/service.go
@@ -107,7 +107,9 @@ func (mts *MetadataService) SubscribeURL(url *common.URL) (bool, error) {
 
 // UnsubscribeURL will be implemented by in memory service
 func (mts *MetadataService) UnsubscribeURL(url *common.URL) error {
-	return mts.UnsubscribeURL(url)
+	// TODO remove call self.
+	return nil
+	//return mts.UnsubscribeURL(url)
 }
 
 // PublishServiceDefinition will call remote metadata's StoreProviderMetadata to store url info and service definition
diff --git a/protocol/dubbo/dubbo_codec.go b/protocol/dubbo/dubbo_codec.go
index 5e859a7fa..ccecbee2e 100644
--- a/protocol/dubbo/dubbo_codec.go
+++ b/protocol/dubbo/dubbo_codec.go
@@ -238,7 +238,6 @@ func (c *DubboCodec) decodeRequest(data []byte) (*remoting.Request, int, error)
 func (c *DubboCodec) decodeResponse(data []byte) (*remoting.Response, int, error) {
 	buf := bytes.NewBuffer(data)
 	pkg := impl.NewDubboPackage(buf)
-	response := &remoting.Response{}
 	err := pkg.Unmarshal()
 	if err != nil {
 		originErr := perrors.Cause(err)
@@ -250,7 +249,7 @@ func (c *DubboCodec) decodeResponse(data []byte) (*remoting.Response, int, error
 
 		return nil, 0, perrors.WithStack(err)
 	}
-	response = &remoting.Response{
+	response := &remoting.Response{
 		ID: pkg.Header.ID,
 		//Version:  pkg.Header.,
 		SerialID: pkg.Header.SerialID,
diff --git a/protocol/dubbo/hessian2/hessian_dubbo_test.go b/protocol/dubbo/hessian2/hessian_dubbo_test.go
index 13dab92ba..eaaf50073 100644
--- a/protocol/dubbo/hessian2/hessian_dubbo_test.go
+++ b/protocol/dubbo/hessian2/hessian_dubbo_test.go
@@ -80,6 +80,7 @@ func doTestHessianEncodeHeader(t *testing.T, packageType PackageType, responseSt
 
 func doTestResponse(t *testing.T, packageType PackageType, responseStatus byte, body interface{}, decodedResponse *DubboResponse, assertFunc func()) {
 	resp, err := doTestHessianEncodeHeader(t, packageType, responseStatus, body)
+	assert.NoError(t, err)
 
 	codecR := NewHessianCodec(bufio.NewReader(bytes.NewReader(resp)))
 
@@ -163,6 +164,7 @@ func TestResponse(t *testing.T) {
 
 func doTestRequest(t *testing.T, packageType PackageType, responseStatus byte, body interface{}) {
 	resp, err := doTestHessianEncodeHeader(t, packageType, responseStatus, body)
+	assert.NoError(t, err)
 
 	codecR := NewHessianCodec(bufio.NewReader(bytes.NewReader(resp)))
 
diff --git a/protocol/rest/server/rest_server.go b/protocol/rest/server/rest_server.go
index 3a1cb1939..b0bf0e07b 100644
--- a/protocol/rest/server/rest_server.go
+++ b/protocol/rest/server/rest_server.go
@@ -257,6 +257,7 @@ func assembleArgsFromQueryParams(methodConfig *rest_config.RestMethodConfig, arg
 		kind := t.Kind()
 		if kind == reflect.Ptr {
 			t = t.Elem()
+			kind = t.Kind()
 		}
 		if kind == reflect.Slice {
 			param = req.QueryParameters(v)
@@ -297,6 +298,7 @@ func assembleArgsFromPathParams(methodConfig *rest_config.RestMethodConfig, args
 		kind := t.Kind()
 		if kind == reflect.Ptr {
 			t = t.Elem()
+			kind = t.Kind()
 		}
 		if kind == reflect.Int {
 			param, err = strconv.Atoi(req.PathParameter(v))
diff --git a/registry/base_registry.go b/registry/base_registry.go
index a6693be3a..ee0d34038 100644
--- a/registry/base_registry.go
+++ b/registry/base_registry.go
@@ -273,6 +273,10 @@ func (r *BaseRegistry) processURL(c *common.URL, f func(string, string) error, c
 	default:
 		return perrors.Errorf("@c{%v} type is not referencer or provider", c)
 	}
+	if err != nil {
+		return perrors.WithMessagef(err, "@c{%v} registry fail", c)
+	}
+
 	encodedURL = url.QueryEscape(rawURL)
 	dubboPath = strings.ReplaceAll(dubboPath, "$", "%24")
 	err = f(dubboPath, encodedURL)
diff --git a/registry/consul/registry.go b/registry/consul/registry.go
index 0b7ba9758..869e1c1d7 100644
--- a/registry/consul/registry.go
+++ b/registry/consul/registry.go
@@ -193,7 +193,7 @@ func (r *consulRegistry) Destroy() {
 		go func() {
 			defer func() {
 				if e := recover(); e != nil {
-					logger.Errorf("consulRegistry destory with panic: %v", e)
+					logger.Errorf("consulRegistry destroy with panic: %v", e)
 				}
 				done <- struct{}{}
 			}()
diff --git a/registry/consul/service_discovery.go b/registry/consul/service_discovery.go
index d8ab93f31..a64fabb1b 100644
--- a/registry/consul/service_discovery.go
+++ b/registry/consul/service_discovery.go
@@ -444,7 +444,7 @@ func (csd *consulServiceDiscovery) buildRegisterInstance(instance registry.Servi
 	metadata = encodeConsulMetadata(metadata)
 	metadata[enable] = strconv.FormatBool(instance.IsEnable())
 	// check
-	check := csd.buildCheck(instance)
+	check := csd.buildCheck()
 
 	return &consul.AgentServiceRegistration{
 		ID:      buildID(instance),
@@ -456,12 +456,7 @@ func (csd *consulServiceDiscovery) buildRegisterInstance(instance registry.Servi
 	}, nil
 }
 
-func (csd *consulServiceDiscovery) buildCheck(instance registry.ServiceInstance) consul.AgentServiceCheck {
-
-	deregister, ok := instance.GetMetadata()[constant.DEREGISTER_AFTER]
-	if !ok || len(deregister) == 0 {
-		deregister = constant.DEFAULT_DEREGISTER_TIME
-	}
+func (csd *consulServiceDiscovery) buildCheck() consul.AgentServiceCheck {
 	return consul.AgentServiceCheck{
 		TTL:                            strconv.FormatInt(csd.checkPassInterval/1000, 10) + "s",
 		DeregisterCriticalServiceAfter: csd.deregisterCriticalServiceAfter,
diff --git a/registry/kubernetes/registry_test.go b/registry/kubernetes/registry_test.go
index 9fb409a22..a816b035c 100644
--- a/registry/kubernetes/registry_test.go
+++ b/registry/kubernetes/registry_test.go
@@ -280,7 +280,7 @@ func TestSubscribe(t *testing.T) {
 		defer wg.Done()
 		registerErr := r.Register(url)
 		if registerErr != nil {
-			t.Fatal(registerErr)
+			t.Error(registerErr)
 		}
 	}()
 
diff --git a/remoting/etcdv3/client_test.go b/remoting/etcdv3/client_test.go
index 3de266f42..da31136ed 100644
--- a/remoting/etcdv3/client_test.go
+++ b/remoting/etcdv3/client_test.go
@@ -298,7 +298,7 @@ func (suite *ClientTestSuite) TestClientWatch() {
 
 		wc, err := c.watch(prefix)
 		if err != nil {
-			t.Fatal(err)
+			t.Error(err)
 		}
 
 		events := make([]mvccpb.Event, 0)
@@ -358,7 +358,7 @@ func (suite *ClientTestSuite) TestClientRegisterTemp() {
 		completePath := path.Join("scott", "wang")
 		wc, err := observeC.watch(completePath)
 		if err != nil {
-			t.Fatal(err)
+			t.Error(err)
 		}
 
 		events := make([]mvccpb.Event, 0)
diff --git a/remoting/getty/dubbo_codec_for_test.go b/remoting/getty/dubbo_codec_for_test.go
index fca5da896..b33fb7422 100644
--- a/remoting/getty/dubbo_codec_for_test.go
+++ b/remoting/getty/dubbo_codec_for_test.go
@@ -230,7 +230,6 @@ func (c *DubboTestCodec) decodeRequest(data []byte) (*remoting.Request, int, err
 func (c *DubboTestCodec) decodeResponse(data []byte) (*remoting.Response, int, error) {
 	buf := bytes.NewBuffer(data)
 	pkg := impl.NewDubboPackage(buf)
-	response := &remoting.Response{}
 	err := pkg.Unmarshal()
 	if err != nil {
 		originErr := perrors.Cause(err)
@@ -240,7 +239,7 @@ func (c *DubboTestCodec) decodeResponse(data []byte) (*remoting.Response, int, e
 		}
 		return nil, 0, perrors.WithStack(err)
 	}
-	response = &remoting.Response{
+	response := &remoting.Response{
 		ID: pkg.Header.ID,
 		//Version:  pkg.Header.,
 		SerialID: pkg.Header.SerialID,
diff --git a/remoting/getty/getty_client.go b/remoting/getty/getty_client.go
index e432ca55a..17b523191 100644
--- a/remoting/getty/getty_client.go
+++ b/remoting/getty/getty_client.go
@@ -110,7 +110,7 @@ func setClientGrpool() {
 // Options : param config
 type Options struct {
 	// connect timeout
-	// remove request timeout, it will be calulate for every request
+	// remove request timeout, it will be calculate for every request
 	ConnectTimeout time.Duration
 	// request timeout
 	RequestTimeout time.Duration
diff --git a/remoting/getty/getty_server.go b/remoting/getty/getty_server.go
index 620a01d83..d7582e2d1 100644
--- a/remoting/getty/getty_server.go
+++ b/remoting/getty/getty_server.go
@@ -160,7 +160,7 @@ func (s *Server) newSession(session getty.Session) error {
 		session.SetTaskPool(srvGrpool)
 		return nil
 	}
-	if tcpConn, ok = session.Conn().(*net.TCPConn); !ok {
+	if _, ok = session.Conn().(*net.TCPConn); !ok {
 		panic(fmt.Sprintf("%s, session.conn{%#v} is not tcp connection\n", session.Stat(), session.Conn()))
 	}
 
diff --git a/remoting/getty/listener_test.go b/remoting/getty/listener_test.go
index 7e7ac5fed..956ecf984 100644
--- a/remoting/getty/listener_test.go
+++ b/remoting/getty/listener_test.go
@@ -47,7 +47,7 @@ func TestRebuildCtx(t *testing.T) {
 	assert.Nil(t, ctx.Value(constant.TRACING_REMOTE_SPAN_CTX))
 
 	span, ctx := opentracing.StartSpanFromContext(ctx, "Test-Client")
-
+	assert.NotNil(t, ctx)
 	err := injectTraceCtx(span, inv)
 	assert.NoError(t, err)
 
diff --git a/remoting/kubernetes/client.go b/remoting/kubernetes/client.go
index fce9e80eb..5399e5f21 100644
--- a/remoting/kubernetes/client.go
+++ b/remoting/kubernetes/client.go
@@ -48,16 +48,16 @@ type Client struct {
 
 // newClient returns Client instance for registry
 func newClient(url *common.URL) (*Client, error) {
-
-	ctx, cancel := context.WithCancel(context.Background())
-
 	// read type
 	r, err := strconv.Atoi(url.GetParams().Get(constant.ROLE_KEY))
 	if err != nil {
 		return nil, perrors.WithMessage(err, "atoi role")
 	}
+	ctx, cancel := context.WithCancel(context.Background())
+
 	controller, err := newDubboRegistryController(ctx, common.RoleType(r), GetInClusterKubernetesClient)
 	if err != nil {
+		cancel()
 		return nil, perrors.WithMessage(err, "new dubbo-registry controller")
 	}
 
diff --git a/remoting/kubernetes/client_test.go b/remoting/kubernetes/client_test.go
index d6c5a2e88..fdaee96b4 100644
--- a/remoting/kubernetes/client_test.go
+++ b/remoting/kubernetes/client_test.go
@@ -365,7 +365,7 @@ func TestClientGetChildrenKVList(t *testing.T) {
 	// start get all children
 	kList, vList, err := client.GetChildren(prefix)
 	if err != nil {
-		t.Fatal(err)
+		t.Error(err)
 	}
 
 	for i := 0; i < len(kList); i++ {
@@ -392,7 +392,7 @@ func TestClientWatchPrefix(t *testing.T) {
 
 		wc, done, err := client.WatchWithPrefix(prefix)
 		if err != nil {
-			t.Fatal(err)
+			t.Error(err)
 		}
 
 		wg.Done()
@@ -435,7 +435,7 @@ func TestClientWatch(t *testing.T) {
 
 		wc, done, err := client.Watch(prefix)
 		if err != nil {
-			t.Fatal(err)
+			t.Error(err)
 		}
 		wg.Done()
 
diff --git a/remoting/kubernetes/registry_controller.go b/remoting/kubernetes/registry_controller.go
index 20be0d72e..f66163d3c 100644
--- a/remoting/kubernetes/registry_controller.go
+++ b/remoting/kubernetes/registry_controller.go
@@ -442,7 +442,7 @@ func (c *dubboRegistryController) initCurrentPod() error {
 		return perrors.WithMessage(err, "get patch")
 	}
 
-	currentPod, err = c.patchCurrentPod(p)
+	_, err = c.patchCurrentPod(p)
 	if err != nil {
 		return perrors.WithMessage(err, "patch to current pod")
 	}
diff --git a/remoting/nacos/builder_test.go b/remoting/nacos/builder_test.go
index 61d13ef26..48199bea4 100644
--- a/remoting/nacos/builder_test.go
+++ b/remoting/nacos/builder_test.go
@@ -34,11 +34,13 @@ func TestNewNacosClient(t *testing.T) {
 	client, err := NewNacosClient(rc)
 
 	// address is nil
+	assert.Nil(t, client)
 	assert.NotNil(t, err)
 
 	rc.Address = "console.nacos.io:80:123"
 	client, err = NewNacosClient(rc)
 	// invalid address
+	assert.Nil(t, client)
 	assert.NotNil(t, err)
 
 	rc.Address = "console.nacos.io:80"
-- 
GitLab