You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2021/01/03 13:31:52 UTC

[dubbo-go] branch develop updated: delete unused var

This is an automated email from the ASF dual-hosted git repository.

alexstocks pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git


The following commit(s) were added to refs/heads/develop by this push:
     new b48fbc1  delete unused var
b48fbc1 is described below

commit b48fbc1d9511a10bcae1c118cc9b875b8f65bc1e
Author: AlexStocks <al...@foxmail.com>
AuthorDate: Sun Jan 3 21:31:35 2021 +0800

    delete unused var
---
 cluster/cluster_impl/failback_cluster_invoker.go |  3 +--
 cluster/router/chain/chain_test.go               |  2 ++
 cluster/router/condition/listenable_router.go    |  4 ++--
 cluster/router/tag/file.go                       |  2 +-
 cluster/router/tag/tag_router.go                 |  2 +-
 cluster/router/tag/tag_router_test.go            |  2 +-
 common/config/environment.go                     |  4 ++--
 config/base_config.go                            |  2 +-
 config/config_center_config.go                   |  6 ++----
 config_center/nacos/client.go                    |  2 +-
 config_center/zookeeper/impl.go                  |  2 +-
 metadata/service/inmemory/service_proxy.go       |  4 ++--
 protocol/dubbo/dubbo_invoker_test.go             |  2 +-
 protocol/jsonrpc/http.go                         | 16 ++++++++--------
 protocol/jsonrpc/http_test.go                    |  2 +-
 registry/base_registry.go                        |  3 +--
 registry/consul/service_discovery.go             |  2 +-
 registry/consul/service_discovery_test.go        |  3 ++-
 registry/directory/directory.go                  |  7 +++----
 registry/nacos/service_discovery_test.go         |  3 ++-
 registry/zookeeper/service_discovery.go          |  6 +++---
 registry/zookeeper/service_discovery_test.go     |  8 ++++++--
 remoting/getty/getty_client_test.go              |  3 ++-
 remoting/kubernetes/facade_test.go               |  7 +++----
 24 files changed, 50 insertions(+), 47 deletions(-)

diff --git a/cluster/cluster_impl/failback_cluster_invoker.go b/cluster/cluster_impl/failback_cluster_invoker.go
index 7654e42..5e0d133 100644
--- a/cluster/cluster_impl/failback_cluster_invoker.go
+++ b/cluster/cluster_impl/failback_cluster_invoker.go
@@ -77,8 +77,7 @@ func (invoker *failbackClusterInvoker) tryTimerTaskProc(ctx context.Context, ret
 	invoked = append(invoked, retryTask.lastInvoker)
 
 	retryInvoker := invoker.doSelect(retryTask.loadbalance, retryTask.invocation, retryTask.invokers, invoked)
-	var result protocol.Result
-	result = retryInvoker.Invoke(ctx, retryTask.invocation)
+	result := retryInvoker.Invoke(ctx, retryTask.invocation)
 	if result.Error() != nil {
 		retryTask.lastInvoker = retryInvoker
 		invoker.checkRetry(retryTask, result.Error())
diff --git a/cluster/router/chain/chain_test.go b/cluster/router/chain/chain_test.go
index 92c59d7..a2b5642 100644
--- a/cluster/router/chain/chain_test.go
+++ b/cluster/router/chain/chain_test.go
@@ -238,6 +238,7 @@ conditions:
 
 func TestRouterChainRouteNoRoute(t *testing.T) {
 	ts, z, _, err := zookeeper.NewMockZookeeperClient("test", 15*time.Second)
+	assert.Nil(t, err)
 	defer func() {
 		err := ts.Stop()
 		assert.NoError(t, err)
@@ -247,6 +248,7 @@ func TestRouterChainRouteNoRoute(t *testing.T) {
 	zkUrl, _ := common.NewURL(fmt.Sprintf(zkFormat, localIP, ts.Servers[0].Port))
 	configuration, err := extension.GetConfigCenterFactory(zk).GetDynamicConfiguration(zkUrl)
 	config.GetEnvInstance().SetDynamicConfiguration(configuration)
+	assert.Nil(t, err)
 
 	chain, err := NewRouterChain(getConditionNoRouteUrl(applicationKey))
 	assert.Nil(t, err)
diff --git a/cluster/router/condition/listenable_router.go b/cluster/router/condition/listenable_router.go
index 0b47310..102d766 100644
--- a/cluster/router/condition/listenable_router.go
+++ b/cluster/router/condition/listenable_router.go
@@ -47,8 +47,8 @@ type listenableRouter struct {
 	conditionRouters []*ConditionRouter
 	routerRule       *RouterRule
 	url              *common.URL
-	force            bool
-	priority         int64
+	//force            bool
+	priority int64
 }
 
 // RouterRule Get RouterRule instance from listenableRouter
diff --git a/cluster/router/tag/file.go b/cluster/router/tag/file.go
index 94daf15..a51ae69 100644
--- a/cluster/router/tag/file.go
+++ b/cluster/router/tag/file.go
@@ -41,7 +41,7 @@ type FileTagRouter struct {
 	router     *tagRouter
 	routerRule *RouterRule
 	url        *common.URL
-	force      bool
+	//force      bool
 }
 
 // NewFileTagRouter Create file tag router instance with content (from config file)
diff --git a/cluster/router/tag/tag_router.go b/cluster/router/tag/tag_router.go
index c7f5304..eca19ea 100644
--- a/cluster/router/tag/tag_router.go
+++ b/cluster/router/tag/tag_router.go
@@ -53,7 +53,7 @@ type addrMetadata struct {
 	// application name
 	application string
 	// is rule a runtime rule
-	ruleRuntime bool
+	//ruleRuntime bool
 	// is rule a force rule
 	ruleForce bool
 	// is rule a valid rule
diff --git a/cluster/router/tag/tag_router_test.go b/cluster/router/tag/tag_router_test.go
index 20b511d..26c4b83 100644
--- a/cluster/router/tag/tag_router_test.go
+++ b/cluster/router/tag/tag_router_test.go
@@ -237,7 +237,7 @@ func TestRouteBeijingInvoker(t *testing.T) {
 
 type DynamicTagRouter struct {
 	suite.Suite
-	rule *RouterRule
+	//rule *RouterRule
 
 	route       *tagRouter
 	zkClient    *zookeeper.ZookeeperClient
diff --git a/common/config/environment.go b/common/config/environment.go
index 44cdd1f..c5651a3 100644
--- a/common/config/environment.go
+++ b/common/config/environment.go
@@ -34,8 +34,8 @@ import (
 // We just have config center configuration which can override configuration in consumer.yaml & provider.yaml.
 // But for add these features in future ,I finish the environment struct following Environment class in java.
 type Environment struct {
-	configCenterFirst    bool
-	externalConfigs      sync.Map
+	configCenterFirst bool
+	//externalConfigs      sync.Map
 	externalConfigMap    sync.Map
 	appExternalConfigMap sync.Map
 	dynamicConfiguration config_center.DynamicConfiguration
diff --git a/config/base_config.go b/config/base_config.go
index 0cc6eec..7cb25a5 100644
--- a/config/base_config.go
+++ b/config/base_config.go
@@ -45,7 +45,7 @@ type BaseConfig struct {
 	// application config
 	ApplicationConfig *ApplicationConfig `yaml:"application" json:"application,omitempty" property:"application"`
 
-	prefix              string
+	//prefix              string
 	fatherConfig        interface{}
 	EventDispatcherType string        `default:"direct" yaml:"event_dispatcher_type" json:"event_dispatcher_type,omitempty"`
 	MetricConfig        *MetricConfig `yaml:"metrics" json:"metrics,omitempty"`
diff --git a/config/config_center_config.go b/config/config_center_config.go
index 3bb8564..940b7be 100644
--- a/config/config_center_config.go
+++ b/config/config_center_config.go
@@ -18,10 +18,8 @@
 package config
 
 import (
-	"context"
 	"net/url"
 	"reflect"
-	"time"
 )
 
 import (
@@ -46,7 +44,7 @@ import (
 //
 // ConfigCenter has currently supported Zookeeper, Nacos, Etcd, Consul, Apollo
 type ConfigCenterConfig struct {
-	context       context.Context
+	//context       context.Context
 	Protocol      string `required:"true"  yaml:"protocol"  json:"protocol,omitempty"`
 	Address       string `yaml:"address" json:"address,omitempty"`
 	Cluster       string `yaml:"cluster" json:"cluster,omitempty"`
@@ -60,7 +58,7 @@ type ConfigCenterConfig struct {
 	AppId         string `default:"dubbo" yaml:"app_id"  json:"app_id,omitempty"`
 	TimeoutStr    string `yaml:"timeout"  json:"timeout,omitempty"`
 	RemoteRef     string `required:"false"  yaml:"remote_ref"  json:"remote_ref,omitempty"`
-	timeout       time.Duration
+	//timeout       time.Duration
 }
 
 // UnmarshalYAML unmarshals the ConfigCenterConfig by @unmarshal function
diff --git a/config_center/nacos/client.go b/config_center/nacos/client.go
index c7d631c..1e96b36 100644
--- a/config_center/nacos/client.go
+++ b/config_center/nacos/client.go
@@ -65,7 +65,7 @@ type option func(*options)
 
 type options struct {
 	nacosName string
-	client    *NacosClient
+	//client    *NacosClient
 }
 
 // WithNacosName Set nacos name
diff --git a/config_center/zookeeper/impl.go b/config_center/zookeeper/impl.go
index 17812e9..f3b2235 100644
--- a/config_center/zookeeper/impl.go
+++ b/config_center/zookeeper/impl.go
@@ -52,7 +52,7 @@ type zookeeperDynamicConfiguration struct {
 	done     chan struct{}
 	client   *zookeeper.ZookeeperClient
 
-	listenerLock  sync.Mutex
+	//listenerLock  sync.Mutex
 	listener      *zookeeper.ZkEventListener
 	cacheListener *CacheListener
 	parser        parser.ConfigurationParser
diff --git a/metadata/service/inmemory/service_proxy.go b/metadata/service/inmemory/service_proxy.go
index 7e14293..98355f1 100644
--- a/metadata/service/inmemory/service_proxy.go
+++ b/metadata/service/inmemory/service_proxy.go
@@ -39,8 +39,8 @@ import (
 // this is the stub, or proxy
 // for now, only GetExportedURLs need to be implemented
 type MetadataServiceProxy struct {
-	invkr        protocol.Invoker
-	golangServer bool
+	invkr protocol.Invoker
+	//golangServer bool
 }
 
 func (m *MetadataServiceProxy) GetExportedURLs(serviceInterface string, group string, version string, protocol string) ([]interface{}, error) {
diff --git a/protocol/dubbo/dubbo_invoker_test.go b/protocol/dubbo/dubbo_invoker_test.go
index c7a9a26..fecb3b0 100644
--- a/protocol/dubbo/dubbo_invoker_test.go
+++ b/protocol/dubbo/dubbo_invoker_test.go
@@ -169,7 +169,7 @@ type (
 	}
 
 	UserProvider struct {
-		user map[string]User
+		//user map[string]User
 	}
 )
 
diff --git a/protocol/jsonrpc/http.go b/protocol/jsonrpc/http.go
index 7ab1a89..037744c 100644
--- a/protocol/jsonrpc/http.go
+++ b/protocol/jsonrpc/http.go
@@ -49,14 +49,14 @@ import (
 
 // Request is HTTP protocol request
 type Request struct {
-	ID          int64
-	group       string
-	protocol    string
-	version     string
-	service     string
-	method      string
-	args        interface{}
-	contentType string
+	ID       int64
+	group    string
+	protocol string
+	version  string
+	service  string
+	method   string
+	args     interface{}
+	//contentType string
 }
 
 // ////////////////////////////////////////////
diff --git a/protocol/jsonrpc/http_test.go b/protocol/jsonrpc/http_test.go
index c4801c8..5ef4064 100644
--- a/protocol/jsonrpc/http_test.go
+++ b/protocol/jsonrpc/http_test.go
@@ -44,7 +44,7 @@ type (
 	}
 
 	UserProvider struct {
-		user map[string]User
+		//user map[string]User
 	}
 )
 
diff --git a/registry/base_registry.go b/registry/base_registry.go
index ee0d340..e97cc1a 100644
--- a/registry/base_registry.go
+++ b/registry/base_registry.go
@@ -18,7 +18,6 @@
 package registry
 
 import (
-	"context"
 	"fmt"
 	"net/url"
 	"os"
@@ -93,7 +92,7 @@ type FacadeBasedRegistry interface {
 
 // BaseRegistry is a common logic abstract for registry. It implement Registry interface.
 type BaseRegistry struct {
-	context             context.Context
+	//context             context.Context
 	facadeBasedRegistry FacadeBasedRegistry
 	*common.URL
 	birth    int64          // time of file birth, seconds since Epoch; 0 if unknown
diff --git a/registry/consul/service_discovery.go b/registry/consul/service_discovery.go
index a64fabb..6674909 100644
--- a/registry/consul/service_discovery.go
+++ b/registry/consul/service_discovery.go
@@ -252,7 +252,7 @@ func (csd *consulServiceDiscovery) GetServices() *gxset.HashSet {
 		return res
 	}
 
-	for service, _ := range services {
+	for service := range services {
 		res.Add(service)
 	}
 	return res
diff --git a/registry/consul/service_discovery_test.go b/registry/consul/service_discovery_test.go
index 348790c..3f97d84 100644
--- a/registry/consul/service_discovery_test.go
+++ b/registry/consul/service_discovery_test.go
@@ -141,7 +141,8 @@ func TestConsulServiceDiscovery_CRUD(t *testing.T) {
 	assert.Equal(t, 1, len(page.GetData()))
 
 	instanceResult = page.GetData()[0].(*registry.DefaultServiceInstance)
-	v, _ := instanceResult.Metadata["aaa"]
+	v, ok := instanceResult.Metadata["aaa"]
+	assert.True(t, ok)
 	assert.Equal(t, "bbb", v)
 
 	// test dispatcher event
diff --git a/registry/directory/directory.go b/registry/directory/directory.go
index f55bd4a..66d021d 100644
--- a/registry/directory/directory.go
+++ b/registry/directory/directory.go
@@ -26,7 +26,6 @@ import (
 
 import (
 	perrors "github.com/pkg/errors"
-	"go.uber.org/atomic"
 )
 
 import (
@@ -64,9 +63,9 @@ type RegistryDirectory struct {
 	configurators                  []config_center.Configurator
 	consumerConfigurationListener  *consumerConfigurationListener
 	referenceConfigurationListener *referenceConfigurationListener
-	serviceKey                     string
-	forbidden                      atomic.Bool
-	registerLock                   sync.Mutex // this lock if for register
+	//serviceKey                     string
+	//forbidden                      atomic.Bool
+	registerLock sync.Mutex // this lock if for register
 }
 
 // NewRegistryDirectory will create a new RegistryDirectory
diff --git a/registry/nacos/service_discovery_test.go b/registry/nacos/service_discovery_test.go
index 3b09136..2af1d5b 100644
--- a/registry/nacos/service_discovery_test.go
+++ b/registry/nacos/service_discovery_test.go
@@ -151,7 +151,8 @@ func TestNacosServiceDiscovery_CRUD(t *testing.T) {
 	assert.Equal(t, 1, len(page.GetData()))
 
 	instance = page.GetData()[0].(*registry.DefaultServiceInstance)
-	v, _ := instance.Metadata["a"]
+	v, ok := instance.Metadata["a"]
+	assert.True(t, ok)
 	assert.Equal(t, "b", v)
 
 	// test dispatcher event
diff --git a/registry/zookeeper/service_discovery.go b/registry/zookeeper/service_discovery.go
index 6d9582f..678c844 100644
--- a/registry/zookeeper/service_discovery.go
+++ b/registry/zookeeper/service_discovery.go
@@ -60,9 +60,9 @@ func init() {
 }
 
 type zookeeperServiceDiscovery struct {
-	client      *zookeeper.ZookeeperClient
-	csd         *curator_discovery.ServiceDiscovery
-	listener    *zookeeper.ZkEventListener
+	client *zookeeper.ZookeeperClient
+	csd    *curator_discovery.ServiceDiscovery
+	//listener    *zookeeper.ZkEventListener
 	url         *common.URL
 	wg          sync.WaitGroup
 	cltLock     sync.Mutex
diff --git a/registry/zookeeper/service_discovery_test.go b/registry/zookeeper/service_discovery_test.go
index 60b3d13..a23cb9d 100644
--- a/registry/zookeeper/service_discovery_test.go
+++ b/registry/zookeeper/service_discovery_test.go
@@ -75,7 +75,9 @@ func TestNewZookeeperServiceDiscovery(t *testing.T) {
 
 func TestCURDZookeeperServiceDiscovery(t *testing.T) {
 	ts := prepareData(t)
-	defer ts.Stop()
+	defer func() {
+		_ = ts.Stop()
+	}()
 	sd, err := newZookeeperServiceDiscovery(testName)
 	assert.Nil(t, err)
 	defer func() {
@@ -143,7 +145,9 @@ func TestCURDZookeeperServiceDiscovery(t *testing.T) {
 
 func TestAddListenerZookeeperServiceDiscovery(t *testing.T) {
 	ts := prepareData(t)
-	defer ts.Stop()
+	defer func() {
+		_ = ts.Stop()
+	}()
 	sd, err := newZookeeperServiceDiscovery(testName)
 	assert.Nil(t, err)
 	defer func() {
diff --git a/remoting/getty/getty_client_test.go b/remoting/getty/getty_client_test.go
index 982c509..c32e0c2 100644
--- a/remoting/getty/getty_client_test.go
+++ b/remoting/getty/getty_client_test.go
@@ -396,6 +396,7 @@ func InitTest(t *testing.T) (*Server, *common.URL) {
 		"environment=dev&interface=com.ikurento.user.UserProvider&ip=127.0.0.1&methods=GetUser%2C&" +
 		"module=dubbogo+user-info+server&org=ikurento.com&owner=ZX&pid=1447&revision=0.0.1&" +
 		"side=provider&timeout=3000&timestamp=1556509797245&bean.name=UserProvider")
+	assert.NoError(t, err)
 	// init server
 	userProvider := &UserProvider{}
 	_, err = common.ServiceMap.Register("", url.Protocol, "", "0.0.1", userProvider)
@@ -432,7 +433,7 @@ type (
 	}
 
 	UserProvider struct {
-		user map[string]User
+		//user map[string]User
 	}
 )
 
diff --git a/remoting/kubernetes/facade_test.go b/remoting/kubernetes/facade_test.go
index 00e2e11..a6c6c02 100644
--- a/remoting/kubernetes/facade_test.go
+++ b/remoting/kubernetes/facade_test.go
@@ -19,7 +19,6 @@ package kubernetes
 
 import (
 	"strconv"
-	"sync"
 	"testing"
 )
 
@@ -30,9 +29,9 @@ import (
 
 type mockFacade struct {
 	*common.URL
-	client  *Client
-	cltLock sync.Mutex
-	done    chan struct{}
+	client *Client
+	//cltLock sync.Mutex
+	//done    chan struct{}
 }
 
 func (r *mockFacade) Client() *Client {