From 974e39018b527f84e044438ba1cb7de63cd1f660 Mon Sep 17 00:00:00 2001
From: wangwx <wangwx@tuya.com>
Date: Sat, 23 Jan 2021 18:01:57 +0800
Subject: [PATCH] fix imports format and ut

---
 config_center/zookeeper/impl.go         | 8 ++++++--
 registry/kubernetes/registry.go         | 7 +++++--
 registry/zookeeper/listener.go          | 8 ++++++--
 registry/zookeeper/registry.go          | 6 +++++-
 registry/zookeeper/service_discovery.go | 8 +++++---
 remoting/zookeeper/client.go            | 8 ++++++--
 remoting/zookeeper/client_test.go       | 7 ++++++-
 remoting/zookeeper/facade.go            | 2 ++
 remoting/zookeeper/facade_test.go       | 7 ++++++-
 remoting/zookeeper/listener.go          | 6 +++++-
 remoting/zookeeper/listener_test.go     | 9 +++++++--
 11 files changed, 59 insertions(+), 17 deletions(-)

diff --git a/config_center/zookeeper/impl.go b/config_center/zookeeper/impl.go
index 8333088a2..7a22f7817 100644
--- a/config_center/zookeeper/impl.go
+++ b/config_center/zookeeper/impl.go
@@ -20,16 +20,20 @@ package zookeeper
 import (
 	"strings"
 	"sync"
+)
 
-	gxset "github.com/dubbogo/gost/container/set"
+import (
+	perrors "github.com/pkg/errors"
+)
 
+import (
 	"github.com/apache/dubbo-go/common"
 	"github.com/apache/dubbo-go/common/constant"
 	"github.com/apache/dubbo-go/common/logger"
 	"github.com/apache/dubbo-go/config_center"
 	"github.com/apache/dubbo-go/config_center/parser"
 	"github.com/apache/dubbo-go/remoting/zookeeper"
-	perrors "github.com/pkg/errors"
+	gxset "github.com/dubbogo/gost/container/set"
 )
 
 const (
diff --git a/registry/kubernetes/registry.go b/registry/kubernetes/registry.go
index 115f21121..a26478f2e 100644
--- a/registry/kubernetes/registry.go
+++ b/registry/kubernetes/registry.go
@@ -22,18 +22,21 @@ import (
 	"path"
 	"sync"
 	"time"
+)
 
+import (
 	getty "github.com/apache/dubbo-getty"
-
 	perrors "github.com/pkg/errors"
+	v1 "k8s.io/api/core/v1"
+)
 
+import (
 	"github.com/apache/dubbo-go/common"
 	"github.com/apache/dubbo-go/common/constant"
 	"github.com/apache/dubbo-go/common/extension"
 	"github.com/apache/dubbo-go/common/logger"
 	"github.com/apache/dubbo-go/registry"
 	"github.com/apache/dubbo-go/remoting/kubernetes"
-	v1 "k8s.io/api/core/v1"
 )
 
 const (
diff --git a/registry/zookeeper/listener.go b/registry/zookeeper/listener.go
index 53084c15d..453cb5741 100644
--- a/registry/zookeeper/listener.go
+++ b/registry/zookeeper/listener.go
@@ -20,14 +20,18 @@ package zookeeper
 import (
 	"strings"
 	"sync"
+)
+
+import (
+	perrors "github.com/pkg/errors"
+)
 
+import (
 	"github.com/apache/dubbo-go/common"
 	"github.com/apache/dubbo-go/common/logger"
 	"github.com/apache/dubbo-go/config_center"
 	"github.com/apache/dubbo-go/registry"
 	"github.com/apache/dubbo-go/remoting"
-	perrors "github.com/pkg/errors"
-
 	zk "github.com/apache/dubbo-go/remoting/zookeeper"
 )
 
diff --git a/registry/zookeeper/registry.go b/registry/zookeeper/registry.go
index 838164607..bce8eb531 100644
--- a/registry/zookeeper/registry.go
+++ b/registry/zookeeper/registry.go
@@ -23,16 +23,20 @@ import (
 	"path"
 	"sync"
 	"time"
+)
 
+import (
 	"github.com/dubbogo/go-zookeeper/zk"
+	perrors "github.com/pkg/errors"
+)
 
+import (
 	"github.com/apache/dubbo-go/common"
 	"github.com/apache/dubbo-go/common/constant"
 	"github.com/apache/dubbo-go/common/extension"
 	"github.com/apache/dubbo-go/common/logger"
 	"github.com/apache/dubbo-go/registry"
 	"github.com/apache/dubbo-go/remoting/zookeeper"
-	perrors "github.com/pkg/errors"
 )
 
 const (
diff --git a/registry/zookeeper/service_discovery.go b/registry/zookeeper/service_discovery.go
index 004fa9733..6ac10f9b1 100644
--- a/registry/zookeeper/service_discovery.go
+++ b/registry/zookeeper/service_discovery.go
@@ -23,11 +23,14 @@ import (
 	"strconv"
 	"strings"
 	"sync"
-
+)
+import (
 	gxset "github.com/dubbogo/gost/container/set"
-
 	gxpage "github.com/dubbogo/gost/hash/page"
+	perrors "github.com/pkg/errors"
+)
 
+import (
 	"github.com/apache/dubbo-go/common"
 	"github.com/apache/dubbo-go/common/constant"
 	"github.com/apache/dubbo-go/common/extension"
@@ -37,7 +40,6 @@ import (
 	"github.com/apache/dubbo-go/remoting"
 	"github.com/apache/dubbo-go/remoting/zookeeper"
 	"github.com/apache/dubbo-go/remoting/zookeeper/curator_discovery"
-	perrors "github.com/pkg/errors"
 )
 
 const (
diff --git a/remoting/zookeeper/client.go b/remoting/zookeeper/client.go
index ba67d8509..4df4a2b20 100644
--- a/remoting/zookeeper/client.go
+++ b/remoting/zookeeper/client.go
@@ -23,12 +23,16 @@ import (
 	"sync"
 	"sync/atomic"
 	"time"
+)
 
+import (
 	"github.com/dubbogo/go-zookeeper/zk"
+	perrors "github.com/pkg/errors"
+)
 
+import (
 	"github.com/apache/dubbo-go/common/constant"
 	"github.com/apache/dubbo-go/common/logger"
-	perrors "github.com/pkg/errors"
 )
 
 const (
@@ -232,7 +236,7 @@ func NewMockZookeeperClient(name string, timeout time.Duration, opts ...Option)
 	if err != nil {
 		return nil, nil, nil, perrors.WithMessagef(err, "zk.Connect")
 	}
-
+	atomic.StoreUint32(&z.valid, 1)
 	return ts, z, event, nil
 }
 
diff --git a/remoting/zookeeper/client_test.go b/remoting/zookeeper/client_test.go
index a5aa98c22..4cff1340e 100644
--- a/remoting/zookeeper/client_test.go
+++ b/remoting/zookeeper/client_test.go
@@ -20,12 +20,17 @@ package zookeeper
 import (
 	"testing"
 	"time"
+)
 
-	"github.com/apache/dubbo-go/common/logger"
+import (
 	"github.com/dubbogo/go-zookeeper/zk"
 	"github.com/stretchr/testify/assert"
 )
 
+import (
+	"github.com/apache/dubbo-go/common/logger"
+)
+
 func verifyEventStateOrder(t *testing.T, c <-chan zk.Event, expectedStates []zk.State, source string) {
 	for _, state := range expectedStates {
 		for {
diff --git a/remoting/zookeeper/facade.go b/remoting/zookeeper/facade.go
index 92c3ea723..4aa327fb0 100644
--- a/remoting/zookeeper/facade.go
+++ b/remoting/zookeeper/facade.go
@@ -20,7 +20,9 @@ package zookeeper
 import (
 	"sync"
 	"time"
+)
 
+import (
 	"github.com/apache/dubbo-go/common"
 	"github.com/apache/dubbo-go/common/logger"
 )
diff --git a/remoting/zookeeper/facade_test.go b/remoting/zookeeper/facade_test.go
index 5e9382ace..dd01fc21a 100644
--- a/remoting/zookeeper/facade_test.go
+++ b/remoting/zookeeper/facade_test.go
@@ -21,12 +21,17 @@ import (
 	"sync"
 	"testing"
 	"time"
+)
 
-	"github.com/apache/dubbo-go/common"
+import (
 	"github.com/dubbogo/go-zookeeper/zk"
 	"github.com/stretchr/testify/assert"
 )
 
+import (
+	"github.com/apache/dubbo-go/common"
+)
+
 type mockFacade struct {
 	client  *ZookeeperClient
 	cltLock sync.Mutex
diff --git a/remoting/zookeeper/listener.go b/remoting/zookeeper/listener.go
index b34a16c3a..d752cdafc 100644
--- a/remoting/zookeeper/listener.go
+++ b/remoting/zookeeper/listener.go
@@ -22,15 +22,19 @@ import (
 	"strings"
 	"sync"
 	"time"
+)
 
+import (
 	getty "github.com/apache/dubbo-getty"
 	"github.com/dubbogo/go-zookeeper/zk"
+	perrors "github.com/pkg/errors"
+)
 
+import (
 	"github.com/apache/dubbo-go/common"
 	"github.com/apache/dubbo-go/common/constant"
 	"github.com/apache/dubbo-go/common/logger"
 	"github.com/apache/dubbo-go/remoting"
-	perrors "github.com/pkg/errors"
 )
 
 var (
diff --git a/remoting/zookeeper/listener_test.go b/remoting/zookeeper/listener_test.go
index 760fe8f17..f56bd95c9 100644
--- a/remoting/zookeeper/listener_test.go
+++ b/remoting/zookeeper/listener_test.go
@@ -22,13 +22,18 @@ import (
 	"sync"
 	"testing"
 	"time"
+)
 
-	"github.com/apache/dubbo-go/common/logger"
-	"github.com/apache/dubbo-go/remoting"
+import (
 	"github.com/dubbogo/go-zookeeper/zk"
 	"github.com/stretchr/testify/assert"
 )
 
+import (
+	"github.com/apache/dubbo-go/common/logger"
+	"github.com/apache/dubbo-go/remoting"
+)
+
 var (
 	dubboPropertiesPath = "/dubbo/dubbo.properties"
 )
-- 
GitLab