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 7e4e7fd chore: Remove unnecessary return and judgement. new 4c483e0 Merge pull request #730 from YongHaoWu/remove-unnecessary-statement 7e4e7fd is described below commit 7e4e7fd216ef8c6fa48bc77f21f3b5ef662053ee Author: YongHaoHu <christopher...@gmail.com> AuthorDate: Sat Aug 29 12:48:59 2020 +0800 chore: Remove unnecessary return and judgement. --- cluster/router/tag/tag_router.go | 1 - common/rpc_service.go | 2 +- common/url.go | 2 +- config/base_config.go | 16 +++------------- config/reference_config.go | 1 - config_center/configurator/override.go | 2 +- protocol/rest/rest_exporter.go | 1 - registry/etcdv3/listener_test.go | 1 - registry/event/service_revision_customizer.go | 2 +- registry/protocol/protocol.go | 2 +- .../zookeeper/curator_discovery/service_discovery.go | 1 - 11 files changed, 8 insertions(+), 23 deletions(-) diff --git a/cluster/router/tag/tag_router.go b/cluster/router/tag/tag_router.go index 0acdf70..12e6eda 100644 --- a/cluster/router/tag/tag_router.go +++ b/cluster/router/tag/tag_router.go @@ -191,7 +191,6 @@ func (c *tagRouter) Process(event *config_center.ConfigChangeEvent) { defer c.mutex.Unlock() c.tagRouterRule = routerRule c.ruleChanged = true - return } // URL gets the url of tagRouter diff --git a/common/rpc_service.go b/common/rpc_service.go index 9ef2b95..eb68a49 100644 --- a/common/rpc_service.go +++ b/common/rpc_service.go @@ -271,7 +271,7 @@ func (sm *serviceMap) UnRegister(interfaceName, protocol, serviceId string) erro sm.mutex.Lock() defer sm.mutex.Unlock() sm.interfaceMap[interfaceName] = make([]*Service, 0, len(svrs)) - for i, _ := range svrs { + for i := range svrs { if i != index { sm.interfaceMap[interfaceName] = append(sm.interfaceMap[interfaceName], svrs[i]) } diff --git a/common/url.go b/common/url.go index c355857..e5fa895 100644 --- a/common/url.go +++ b/common/url.go @@ -222,7 +222,7 @@ func NewURL(urlString string, opts ...option) (URL, error) { } // rawUrlString = "//" + rawUrlString - if strings.Index(rawUrlString, "//") < 0 { + if !strings.Contains(rawUrlString, "//") { t := URL{baseUrl: baseUrl{}} for _, opt := range opts { opt(&t) diff --git a/config/base_config.go b/config/base_config.go index 22a0832..336bb03 100644 --- a/config/base_config.go +++ b/config/base_config.go @@ -78,15 +78,8 @@ func getKeyPrefix(val reflect.Value) []string { } else { prefix = val.MethodByName(configPrefixMethod).Call(nil)[0].String() } - var retPrefixes []string - - for _, pfx := range strings.Split(prefix, "|") { - - retPrefixes = append(retPrefixes, pfx) - - } - return retPrefixes + return strings.Split(prefix, "|") } func getPtrElement(v reflect.Value) reflect.Value { @@ -216,12 +209,9 @@ func setFieldValue(val reflect.Value, id reflect.Value, config *config.InmemoryC prefix := s.MethodByName("Prefix").Call(nil)[0].String() for _, pfx := range strings.Split(prefix, "|") { m := config.GetSubProperty(pfx) - if m != nil { - for k := range m { - f.SetMapIndex(reflect.ValueOf(k), reflect.New(f.Type().Elem().Elem())) - } + for k := range m { + f.SetMapIndex(reflect.ValueOf(k), reflect.New(f.Type().Elem().Elem())) } - } } diff --git a/config/reference_config.go b/config/reference_config.go index bbc8751..cd10f89 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -251,5 +251,4 @@ func (c *ReferenceConfig) GenericLoad(id string) { c.id = id c.Refer(genericService) c.Implement(genericService) - return } diff --git a/config_center/configurator/override.go b/config_center/configurator/override.go index 294a60e..ec4e606 100644 --- a/config_center/configurator/override.go +++ b/config_center/configurator/override.go @@ -110,7 +110,7 @@ func (c *overrideConfigurator) configureIfMatchInternal(url *common.URL) { func (c *overrideConfigurator) configureIfMatch(host string, url *common.URL) { if constant.ANYHOST_VALUE == c.configuratorUrl.Ip || host == c.configuratorUrl.Ip { providers := c.configuratorUrl.GetParam(constant.OVERRIDE_PROVIDERS_KEY, "") - if len(providers) == 0 || strings.Index(providers, url.Location) >= 0 || strings.Index(providers, constant.ANYHOST_VALUE) >= 0 { + if len(providers) == 0 || strings.Contains(providers, url.Location) || strings.Contains(providers, constant.ANYHOST_VALUE) { c.configureIfMatchInternal(url) } } diff --git a/protocol/rest/rest_exporter.go b/protocol/rest/rest_exporter.go index e39558c..359506a 100644 --- a/protocol/rest/rest_exporter.go +++ b/protocol/rest/rest_exporter.go @@ -49,5 +49,4 @@ func (re *RestExporter) Unexport() { if err != nil { logger.Errorf("[RestExporter.Unexport] error: %v", err) } - return } diff --git a/registry/etcdv3/listener_test.go b/registry/etcdv3/listener_test.go index cc4ea25..1cf06d1 100644 --- a/registry/etcdv3/listener_test.go +++ b/registry/etcdv3/listener_test.go @@ -63,7 +63,6 @@ func (suite *RegistryTestSuite) SetupSuite() { } suite.etcd = e - return } // stop etcd server diff --git a/registry/event/service_revision_customizer.go b/registry/event/service_revision_customizer.go index fd21e8f..4793e91 100644 --- a/registry/event/service_revision_customizer.go +++ b/registry/event/service_revision_customizer.go @@ -126,7 +126,7 @@ func resolveRevision(urls []interface{}) string { // append url params if we need it } - sort.Sort(sort.StringSlice(candidates)) + sort.Strings(candidates) // it's nearly impossible to be overflow res := uint64(0) diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go index c0608ad..659afe8 100644 --- a/registry/protocol/protocol.go +++ b/registry/protocol/protocol.go @@ -103,7 +103,7 @@ func filterHideKey(url *common.URL) *common.URL { // be careful params maps in url is map type removeSet := gxset.NewSet() - for k, _ := range url.GetParams() { + for k := range url.GetParams() { if strings.HasPrefix(k, ".") { removeSet.Add(k) } diff --git a/remoting/zookeeper/curator_discovery/service_discovery.go b/remoting/zookeeper/curator_discovery/service_discovery.go index 9566b54..acd43c0 100644 --- a/remoting/zookeeper/curator_discovery/service_discovery.go +++ b/remoting/zookeeper/curator_discovery/service_discovery.go @@ -154,7 +154,6 @@ func (sd *ServiceDiscovery) updateInternalService(name, id string) { return } entry.instance = instance - return } // UnregisterService un-register service in zookeeper and delete service in cache