From 0adb3a9286a40cd4a685306c60aa69d423dd653c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E8=BE=9B=E6=A0=BC?= <xg.gao@tianrang-inc.com> Date: Wed, 3 Jul 2019 11:10:56 +0800 Subject: [PATCH] go fmt --- examples/consul/go-client/client.go | 10 +++++----- examples/consul/go-server/server.go | 14 +++++++------- examples/consul/go-server/service.go | 2 +- registry/consul/listener.go | 6 +++--- registry/consul/registry.go | 8 ++++---- registry/consul/utils.go | 6 +++--- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/examples/consul/go-client/client.go b/examples/consul/go-client/client.go index 4ce28de00..73a9bc9c3 100644 --- a/examples/consul/go-client/client.go +++ b/examples/consul/go-client/client.go @@ -22,14 +22,14 @@ import ( ) import ( - _ "github.com/apache/dubbo-go/common/proxy/proxy_factory" - _ "github.com/apache/dubbo-go/protocol/dubbo" - _ "github.com/apache/dubbo-go/registry/protocol" - _ "github.com/apache/dubbo-go/filter/impl" _ "github.com/apache/dubbo-go/cluster/cluster_impl" _ "github.com/apache/dubbo-go/cluster/loadbalance" - _ "github.com/apache/dubbo-go/registry/consul" + _ "github.com/apache/dubbo-go/common/proxy/proxy_factory" "github.com/apache/dubbo-go/config" + _ "github.com/apache/dubbo-go/filter/impl" + _ "github.com/apache/dubbo-go/protocol/dubbo" + _ "github.com/apache/dubbo-go/registry/consul" + _ "github.com/apache/dubbo-go/registry/protocol" ) func main() { diff --git a/examples/consul/go-server/server.go b/examples/consul/go-server/server.go index 040194a1d..fc9786fa2 100644 --- a/examples/consul/go-server/server.go +++ b/examples/consul/go-server/server.go @@ -18,23 +18,23 @@ package main import ( + "fmt" "os" "os/signal" "syscall" "time" - "fmt" ) import ( - _ "github.com/apache/dubbo-go/protocol/dubbo" - _ "github.com/apache/dubbo-go/registry/protocol" - _ "github.com/apache/dubbo-go/common/proxy/proxy_factory" - _ "github.com/apache/dubbo-go/filter/impl" _ "github.com/apache/dubbo-go/cluster/cluster_impl" _ "github.com/apache/dubbo-go/cluster/loadbalance" - _ "github.com/apache/dubbo-go/registry/consul" - "github.com/apache/dubbo-go/config" "github.com/apache/dubbo-go/common/logger" + _ "github.com/apache/dubbo-go/common/proxy/proxy_factory" + "github.com/apache/dubbo-go/config" + _ "github.com/apache/dubbo-go/filter/impl" + _ "github.com/apache/dubbo-go/protocol/dubbo" + _ "github.com/apache/dubbo-go/registry/consul" + _ "github.com/apache/dubbo-go/registry/protocol" ) var ( diff --git a/examples/consul/go-server/service.go b/examples/consul/go-server/service.go index bcd127f35..0cdfd9c07 100644 --- a/examples/consul/go-server/service.go +++ b/examples/consul/go-server/service.go @@ -25,7 +25,7 @@ func init() { config.SetProviderService(new(DubboService)) } -type DubboService struct {} +type DubboService struct{} func (s *DubboService) SayHello(message string) (string, error) { return "hello " + message, nil diff --git a/registry/consul/listener.go b/registry/consul/listener.go index 1604ffc97..d697ce202 100644 --- a/registry/consul/listener.go +++ b/registry/consul/listener.go @@ -22,9 +22,9 @@ import ( ) import ( - perrors "github.com/pkg/errors" consul "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/api/watch" + perrors "github.com/pkg/errors" ) import ( @@ -181,9 +181,9 @@ func (l *consulListener) handler(idx uint64, raw interface{}) { func (l *consulListener) Next() (*registry.ServiceEvent, error) { select { - case event := <- l.eventCh: + case event := <-l.eventCh: return event, nil - case err := <- l.errCh: + case err := <-l.errCh: return nil, err } } diff --git a/registry/consul/registry.go b/registry/consul/registry.go index 5197b47d4..a9510a26d 100644 --- a/registry/consul/registry.go +++ b/registry/consul/registry.go @@ -27,9 +27,9 @@ import ( import ( "github.com/apache/dubbo-go/common" - "github.com/apache/dubbo-go/registry" "github.com/apache/dubbo-go/common/constant" "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/registry" ) func init() { @@ -47,7 +47,7 @@ type consulRegistry struct { // Done field represents whether // consul registry is closed. - done chan struct{} + done chan struct{} } func newConsulRegistry(url *common.URL) (registry.Registry, error) { @@ -107,7 +107,7 @@ func (r *consulRegistry) unregister(url common.URL) error { func (r *consulRegistry) Subscribe(url common.URL) (registry.Listener, error) { var ( listener registry.Listener - err error + err error ) role, _ := strconv.Atoi(r.URL.GetParam(constant.ROLE_KEY, "")) @@ -131,7 +131,7 @@ func (r *consulRegistry) GetUrl() common.URL { func (r *consulRegistry) IsAvailable() bool { select { - case <- r.done: + case <-r.done: return false default: return true diff --git a/registry/consul/utils.go b/registry/consul/utils.go index f24d13169..71b6b0d26 100644 --- a/registry/consul/utils.go +++ b/registry/consul/utils.go @@ -20,14 +20,14 @@ package consul import ( "context" "crypto/md5" - "strconv" "encoding/hex" "fmt" + "strconv" ) import ( - perrors "github.com/pkg/errors" consul "github.com/hashicorp/consul/api" + perrors "github.com/pkg/errors" ) import ( @@ -63,7 +63,7 @@ func buildService(url common.URL) (*consul.AgentServiceRegistration, error) { // tags tags := make([]string, 0) for k := range url.Params { - tags = append(tags, k + "=" + url.Params.Get(k)) + tags = append(tags, k+"="+url.Params.Get(k)) } tags = append(tags, "dubbo") -- GitLab