diff --git a/cluster/router/tag/tag_router.go b/cluster/router/tag/tag_router.go index 0acdf70ce97b7e1984d32ae9d4fc1b50d97ba071..12e6eda3e7fcb7ad28ded327ddfeb07288be5cd9 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 9ef2b956aa955f4fc79c6f75bd060ccfee2d02ca..eb68a49f72a35d31a5908071ab383a094a591a21 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 c355857b9f0bd1d003172035bc84c873229442e8..e5fa895adb80fb327c712d5d95d2479cc897f970 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 22a0832731daff6c9957d4913a3784c9b268b11f..336bb03c7b61ad8aad8465bb3c7754abeb9e9f5a 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 bbc875192c7a87354ccc81e28ea05bbc3bb71149..cd10f89eb7773e16ed953623c6fb38dcb98b01b4 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 294a60ebb2e4e18cfc47cd90aedeaa615b5626d2..ec4e606e0dff300729e2a2bc56f510db94ea9f26 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 e39558caeae9811817cc26a1717c1b8e3729234c..359506a842437ba15c121c29b50478ae775a8ed7 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 cc4ea257ccabb5591689ec961ae279e12f24dd29..1cf06d17dcd4c92afc5221dab404e9d180c03e6c 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 fd21e8f4c7a71cedfe1de7e9c836e7cee278182e..4793e91948fe4c30fffbfd21f0dcc3efe57c5095 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 c0608ad7989e69c104f07aa95e9a77fb9ac212fa..659afe86b1c8f06773a11332c8b81e6be0ac824a 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 9566b5494389325520b4eb6a8eb170e0b305bb47..acd43c0b92bd6220efc6527efc1748ed3021f7ac 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