diff --git a/common/proxy/proxy.go b/common/proxy/proxy.go index d51ce1cc1bf40a8ad25804c797eeed3b88e7d132..c91aafecd7b0c21b034365ce92292e1cb82e455d 100644 --- a/common/proxy/proxy.go +++ b/common/proxy/proxy.go @@ -66,7 +66,6 @@ func NewProxy(invoke protocol.Invoker, callBack interface{}, attachments map[str // Yyy func(ctx context.Context, args []interface{}, rsp *Zzz) error // } func (p *Proxy) Implement(v common.RPCService) { - // check parameters, incoming interface must be a elem's pointer. valueOf := reflect.ValueOf(v) logger.Debugf("[Implement] reflect.TypeOf: %s", valueOf.String()) @@ -145,7 +144,7 @@ func (p *Proxy) Implement(v common.RPCService) { inv.SetAttachments(k, value) } - // add user setAttachment. It is compatibility with previous versions. + // add user setAttachment. It is compatibility with previous versions. atm := invCtx.Value(constant.AttachmentKey) if m, ok := atm.(map[string]string); ok { for k, value := range m { diff --git a/config/application_config.go b/config/application_config.go index ef99664fa298c28365ed7acc54d0c18a88c9b5c2..6fe6c5d049f8ce95a56fcfd62eb1cffc03bf3c43 100644 --- a/config/application_config.go +++ b/config/application_config.go @@ -48,8 +48,5 @@ func (c *ApplicationConfig) UnmarshalYAML(unmarshal func(interface{}) error) err return err } type plain ApplicationConfig - if err := unmarshal((*plain)(c)); err != nil { - return err - } - return nil + return unmarshal((*plain)(c)) } diff --git a/config/base_config.go b/config/base_config.go index 336bb03c7b61ad8aad8465bb3c7754abeb9e9f5a..0cc6eec26c51cb7dfc164a3d43545f6b22658ca0 100644 --- a/config/base_config.go +++ b/config/base_config.go @@ -33,10 +33,6 @@ import ( "github.com/apache/dubbo-go/common/logger" ) -type multiConfiger interface { - Prefix() string -} - // BaseConfig is the common configuration for provider and consumer type BaseConfig struct { ConfigCenterConfig *ConfigCenterConfig `yaml:"config_center" json:"config_center,omitempty"` diff --git a/config/config_center_config.go b/config/config_center_config.go index 752d9d45855c886a1d5122c6e7832196c7e9413b..3bb856415d77344658055f03ccc4a6edd8c0f48a 100644 --- a/config/config_center_config.go +++ b/config/config_center_config.go @@ -26,6 +26,7 @@ import ( import ( "github.com/creasty/defaults" + perrors "github.com/pkg/errors" ) import ( @@ -35,7 +36,6 @@ import ( "github.com/apache/dubbo-go/common/extension" "github.com/apache/dubbo-go/common/logger" "github.com/apache/dubbo-go/config_center" - perrors "github.com/pkg/errors" ) // ConfigCenterConfig is configuration for config center @@ -69,10 +69,7 @@ func (c *ConfigCenterConfig) UnmarshalYAML(unmarshal func(interface{}) error) er return err } type plain ConfigCenterConfig - if err := unmarshal((*plain)(c)); err != nil { - return err - } - return nil + return unmarshal((*plain)(c)) } // GetUrlMap gets url map from ConfigCenterConfig diff --git a/config/consumer_config.go b/config/consumer_config.go index c8083603e12570a4492dd63a749adb4aa89663c8..ff53366c45406dde8e4c0daac7a5d68aa6bd8934 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -71,10 +71,7 @@ func (c *ConsumerConfig) UnmarshalYAML(unmarshal func(interface{}) error) error return err } type plain ConsumerConfig - if err := unmarshal((*plain)(c)); err != nil { - return err - } - return nil + return unmarshal((*plain)(c)) } // nolint diff --git a/config/method_config.go b/config/method_config.go index b64306fd6aa865d219506ea2722067619b00fea7..db52940c3db6b4b81b0467945b538c9b540cd46a 100644 --- a/config/method_config.go +++ b/config/method_config.go @@ -57,8 +57,5 @@ func (c *MethodConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { return err } type plain MethodConfig - if err := unmarshal((*plain)(c)); err != nil { - return err - } - return nil + return unmarshal((*plain)(c)) } diff --git a/config/provider_config.go b/config/provider_config.go index fcb429b6400936f72c09035968b4d4c72387246c..0aee5600298233b764df75b02c745a3ec8d9faef 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -58,10 +58,7 @@ func (c *ProviderConfig) UnmarshalYAML(unmarshal func(interface{}) error) error return err } type plain ProviderConfig - if err := unmarshal((*plain)(c)); err != nil { - return err - } - return nil + return unmarshal((*plain)(c)) } // nolint diff --git a/config/reference_config.go b/config/reference_config.go index e616a3595b85effa25534146e659fae5f0996b41..05df3477362561644a841b147d67a660536ffdbc 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -86,11 +86,7 @@ func (c *ReferenceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error } *c = ReferenceConfig(raw) - if err := defaults.Set(c); err != nil { - return err - } - - return nil + return defaults.Set(c) } // Refer ... diff --git a/config/registry_config.go b/config/registry_config.go index 5aff45dc9f4dd20022255ada04cff78bbf295f3e..ed81a07c637e5de2972bbbd21dab8847c3d42f78 100644 --- a/config/registry_config.go +++ b/config/registry_config.go @@ -63,10 +63,7 @@ func (c *RegistryConfig) UnmarshalYAML(unmarshal func(interface{}) error) error return err } type plain RegistryConfig - if err := unmarshal((*plain)(c)); err != nil { - return err - } - return nil + return unmarshal((*plain)(c)) } // nolint diff --git a/metrics/prometheus/reporter.go b/metrics/prometheus/reporter.go index 810a13d87ce938a3b8a9d085f6d5ae6e3dc4c6ad..266c8206c5ea5b6dc07402943bcebdeb6dd7dea7 100644 --- a/metrics/prometheus/reporter.go +++ b/metrics/prometheus/reporter.go @@ -24,6 +24,7 @@ import ( "sync" "time" ) + import ( "github.com/prometheus/client_golang/prometheus" ) @@ -64,7 +65,6 @@ var ( // should initialize after loading configuration func init() { - extension.SetMetricReporter(reporterName, newPrometheusReporter) } @@ -72,12 +72,10 @@ func init() { // if you want to use this feature, you need to initialize your prometheus. // https://prometheus.io/docs/guides/go-application/ type PrometheusReporter struct { - // report the consumer-side's summary data consumerSummaryVec *prometheus.SummaryVec // report the provider-side's summary data providerSummaryVec *prometheus.SummaryVec - // report the provider-side's histogram data providerHistogramVec *prometheus.HistogramVec // report the consumer-side's histogram data diff --git a/metrics/prometheus/reporter_test.go b/metrics/prometheus/reporter_test.go index eaba0e324ff078bdfb2fd4b146ac9ea60d429724..1b9853f4d20739269861aac680b1ec491ef552d6 100644 --- a/metrics/prometheus/reporter_test.go +++ b/metrics/prometheus/reporter_test.go @@ -26,6 +26,7 @@ import ( import ( "github.com/stretchr/testify/assert" ) + import ( "github.com/apache/dubbo-go/common" "github.com/apache/dubbo-go/common/extension" diff --git a/metrics/reporter.go b/metrics/reporter.go index 9a7094fa62d9c0fa3e6ee0a8ef373f91c28d2c90..24d75aa4fe949737d7ca94cfd339a32af14a40be 100644 --- a/metrics/reporter.go +++ b/metrics/reporter.go @@ -21,6 +21,7 @@ import ( "context" "time" ) + import ( "github.com/apache/dubbo-go/protocol" ) diff --git a/protocol/jsonrpc/jsonrpc_invoker.go b/protocol/jsonrpc/jsonrpc_invoker.go index f10aaad824cea9c953cf994bd7349b57f6bfffa8..357443f5d4efbe5159fb6c0e09d3dab51266dc73 100644 --- a/protocol/jsonrpc/jsonrpc_invoker.go +++ b/protocol/jsonrpc/jsonrpc_invoker.go @@ -45,10 +45,7 @@ func NewJsonrpcInvoker(url *common.URL, client *HTTPClient) *JsonrpcInvoker { // Invoke the JSON RPC invocation and return result. func (ji *JsonrpcInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result { - - var ( - result protocol.RPCResult - ) + var result protocol.RPCResult inv := invocation.(*invocation_impl.RPCInvocation) url := ji.GetUrl() diff --git a/registry/consul/utils.go b/registry/consul/utils.go index 468dafb338e8413c66d00da974c860708a2e2210..76f5d2dd3378f67d300d10b4c5ecc72934ef7715 100644 --- a/registry/consul/utils.go +++ b/registry/consul/utils.go @@ -107,7 +107,7 @@ func retrieveURL(service *consul.ServiceEntry) (*common.URL, error) { func in(url *common.URL, urls []*common.URL) bool { for _, url1 := range urls { - if url.URLEqual(url1) { + if common.IsEquals(url, url1) { return true } }