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/02 18:27:40 UTC
[dubbo-go] branch develop updated: fix common linter error
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 1253721 fix common linter error
1253721 is described below
commit 1253721b7fd13a8cfc3eb6f4139c498ffff3ce96
Author: AlexStocks <al...@foxmail.com>
AuthorDate: Sun Jan 3 02:27:24 2021 +0800
fix common linter error
---
common/logger/logger.go | 5 +++--
common/proxy/proxy_test.go | 8 ++++++--
common/url.go | 38 +++++++++++++++++++++++---------------
3 files changed, 32 insertions(+), 19 deletions(-)
diff --git a/common/logger/logger.go b/common/logger/logger.go
index 63eda23..4a2f07c 100644
--- a/common/logger/logger.go
+++ b/common/logger/logger.go
@@ -163,6 +163,7 @@ type OpsLogger interface {
// SetLoggerLevel use for set logger level
func (dl *DubboLogger) SetLoggerLevel(level string) {
l := new(zapcore.Level)
- l.Set(level)
- dl.dynamicLevel.SetLevel(*l)
+ if err := l.Set(level); err == nil {
+ dl.dynamicLevel.SetLevel(*l)
+ }
}
diff --git a/common/proxy/proxy_test.go b/common/proxy/proxy_test.go
index c6f6596..cbac1f3 100644
--- a/common/proxy/proxy_test.go
+++ b/common/proxy/proxy_test.go
@@ -19,6 +19,7 @@ package proxy
import (
"context"
+ "fmt"
"reflect"
"testing"
)
@@ -145,11 +146,14 @@ type TestProxyInvoker struct {
protocol.BaseInvoker
}
-func (bi *TestProxyInvoker) Invoke(context context.Context, inv protocol.Invocation) protocol.Result {
+func (bi *TestProxyInvoker) Invoke(_ context.Context, inv protocol.Invocation) protocol.Result {
rpcInv := inv.(*invocation.RPCInvocation)
mapV := inv.Attachments()
mapV["TestProxyInvoker"] = "TestProxyInvokerValue"
- hessian2.ReflectResponse(mapV, rpcInv.Reply())
+ if err := hessian2.ReflectResponse(mapV, rpcInv.Reply()); err != nil {
+ fmt.Printf("hessian2.ReflectResponse(mapV:%v) = error:%v", mapV, err)
+ }
+
return &protocol.RPCResult{
Rest: inv.Arguments(),
}
diff --git a/common/url.go b/common/url.go
index 1ea2bc4..8faa0f0 100644
--- a/common/url.go
+++ b/common/url.go
@@ -21,7 +21,6 @@ import (
"bytes"
"encoding/base64"
"fmt"
- cm "github.com/Workiva/go-datastructures/common"
"math"
"net"
"net/url"
@@ -31,7 +30,9 @@ import (
)
import (
+ cm "github.com/Workiva/go-datastructures/common"
gxset "github.com/dubbogo/gost/container/set"
+
"github.com/jinzhu/copier"
perrors "github.com/pkg/errors"
"github.com/satori/go.uuid"
@@ -217,12 +218,12 @@ func WithToken(token string) Option {
// NewURLWithOptions will create a new url with options
func NewURLWithOptions(opts ...Option) *URL {
- newUrl := &URL{}
+ newURL := &URL{}
for _, opt := range opts {
- opt(newUrl)
+ opt(newURL)
}
- newUrl.Location = newUrl.Ip + ":" + newUrl.Port
- return newUrl
+ newURL.Location = newURL.Ip + ":" + newURL.Port
+ return newURL
}
// NewURL will create a new url
@@ -679,27 +680,34 @@ func MergeUrl(serviceUrl *URL, referenceUrl *URL) *URL {
// Clone will copy the url
func (c *URL) Clone() *URL {
- newUrl := &URL{}
- copier.Copy(newUrl, c)
- newUrl.params = url.Values{}
+ newURL := &URL{}
+ if err := copier.Copy(newURL, c); err != nil {
+ // this is impossible
+ return newURL
+ }
+ newURL.params = url.Values{}
c.RangeParams(func(key, value string) bool {
- newUrl.SetParam(key, value)
+ newURL.SetParam(key, value)
return true
})
- return newUrl
+
+ return newURL
}
func (c *URL) CloneExceptParams(excludeParams *gxset.HashSet) *URL {
- newUrl := &URL{}
- copier.Copy(newUrl, c)
- newUrl.params = url.Values{}
+ newURL := &URL{}
+ if err := copier.Copy(newURL, c); err != nil {
+ // this is impossible
+ return newURL
+ }
+ newURL.params = url.Values{}
c.RangeParams(func(key, value string) bool {
if !excludeParams.Contains(key) {
- newUrl.SetParam(key, value)
+ newURL.SetParam(key, value)
}
return true
})
- return newUrl
+ return newURL
}
func (c *URL) Compare(comp cm.Comparator) int {