From d7b9412a136654ff353f5f76e815876d6b8ad132 Mon Sep 17 00:00:00 2001
From: "vito.he" <hxmhlt@163.com>
Date: Mon, 10 Jun 2019 16:01:52 +0800
Subject: [PATCH] Mod: format the code & add apache license

---
 common/configuration_listener.go              | 17 +++++++++++
 config_center/dynamic_configuration.go        |  4 ++-
 .../zookeeper/dynamic_configuration.go        |  4 ++-
 .../{dataListener.go => listener.go}          | 23 ++++++++++++++-
 registry/zookeeper/registry.go                |  2 +-
 registry/zookeeper/registry_test.go           |  2 +-
 remoting/zookeeper/client.go                  |  8 ++++--
 remoting/zookeeper/container.go               | 28 +++++++++++++++++--
 remoting/zookeeper/dataListener.go            |  5 ----
 remoting/zookeeper/listener.go                |  6 +++-
 10 files changed, 82 insertions(+), 17 deletions(-)
 rename registry/zookeeper/{dataListener.go => listener.go} (76%)
 delete mode 100644 remoting/zookeeper/dataListener.go

diff --git a/common/configuration_listener.go b/common/configuration_listener.go
index 25f02da6f..b322256e3 100644
--- a/common/configuration_listener.go
+++ b/common/configuration_listener.go
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package common
 
 import "fmt"
diff --git a/config_center/dynamic_configuration.go b/config_center/dynamic_configuration.go
index 4f388a7dd..57b04f744 100644
--- a/config_center/dynamic_configuration.go
+++ b/config_center/dynamic_configuration.go
@@ -18,9 +18,11 @@
 package config_center
 
 import (
-	"github.com/apache/dubbo-go/common"
 	"time"
 )
+import (
+	"github.com/apache/dubbo-go/common"
+)
 
 //////////////////////////////////////////
 // DynamicConfiguration
diff --git a/config_center/zookeeper/dynamic_configuration.go b/config_center/zookeeper/dynamic_configuration.go
index 7c5ca4487..b94f18a69 100644
--- a/config_center/zookeeper/dynamic_configuration.go
+++ b/config_center/zookeeper/dynamic_configuration.go
@@ -17,13 +17,15 @@
 
 package zookeeper
 
+import (
+	"sync"
+)
 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/remoting/zookeeper"
-	"sync"
 )
 
 const ZkClient = "zk config_center"
diff --git a/registry/zookeeper/dataListener.go b/registry/zookeeper/listener.go
similarity index 76%
rename from registry/zookeeper/dataListener.go
rename to registry/zookeeper/listener.go
index 792db4c7c..f30f2e29d 100644
--- a/registry/zookeeper/dataListener.go
+++ b/registry/zookeeper/listener.go
@@ -1,12 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package zookeeper
 
 import (
 	"context"
+)
+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/registry"
 	zk "github.com/apache/dubbo-go/remoting/zookeeper"
-	perrors "github.com/pkg/errors"
 )
 
 type RegistryDataListener struct {
diff --git a/registry/zookeeper/registry.go b/registry/zookeeper/registry.go
index 018418670..8f9e865d5 100644
--- a/registry/zookeeper/registry.go
+++ b/registry/zookeeper/registry.go
@@ -29,7 +29,6 @@ import (
 )
 
 import (
-	"github.com/apache/dubbo-go/common/logger"
 	perrors "github.com/pkg/errors"
 	"github.com/samuel/go-zookeeper/zk"
 )
@@ -38,6 +37,7 @@ 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/common/utils"
 	"github.com/apache/dubbo-go/registry"
 	"github.com/apache/dubbo-go/remoting/zookeeper"
diff --git a/registry/zookeeper/registry_test.go b/registry/zookeeper/registry_test.go
index aac6b883d..ba2755fa9 100644
--- a/registry/zookeeper/registry_test.go
+++ b/registry/zookeeper/registry_test.go
@@ -19,7 +19,6 @@ package zookeeper
 
 import (
 	"context"
-	"github.com/apache/dubbo-go/remoting/zookeeper"
 	"strconv"
 	"testing"
 	"time"
@@ -32,6 +31,7 @@ import (
 import (
 	"github.com/apache/dubbo-go/common"
 	"github.com/apache/dubbo-go/common/constant"
+	"github.com/apache/dubbo-go/remoting/zookeeper"
 )
 
 func Test_Register(t *testing.T) {
diff --git a/remoting/zookeeper/client.go b/remoting/zookeeper/client.go
index d431822ff..93382ed26 100644
--- a/remoting/zookeeper/client.go
+++ b/remoting/zookeeper/client.go
@@ -18,7 +18,6 @@
 package zookeeper
 
 import (
-	"github.com/apache/dubbo-go/common/constant"
 	"path"
 	"strings"
 	"sync"
@@ -26,11 +25,15 @@ import (
 )
 
 import (
-	"github.com/apache/dubbo-go/common/logger"
 	perrors "github.com/pkg/errors"
 	"github.com/samuel/go-zookeeper/zk"
 )
 
+import (
+	"github.com/apache/dubbo-go/common/constant"
+	"github.com/apache/dubbo-go/common/logger"
+)
+
 const (
 	ConnDelay    = 3
 	MaxFailTimes = 15
@@ -220,7 +223,6 @@ func NewMockZookeeperClient(name string, timeout time.Duration, opts ...Option)
 	return ts, z, event, nil
 }
 
-
 func (z *ZookeeperClient) HandleZkEvent(session <-chan zk.Event) {
 	var (
 		state int
diff --git a/remoting/zookeeper/container.go b/remoting/zookeeper/container.go
index fe262adb2..f869b3244 100644
--- a/remoting/zookeeper/container.go
+++ b/remoting/zookeeper/container.go
@@ -1,12 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package zookeeper
 
 import (
-	"github.com/apache/dubbo-go/common"
-	"github.com/apache/dubbo-go/common/logger"
-	perrors "github.com/pkg/errors"
 	"sync"
 	"time"
 )
+import (
+	perrors "github.com/pkg/errors"
+)
+
+import (
+	"github.com/apache/dubbo-go/common"
+	"github.com/apache/dubbo-go/common/logger"
+)
 
 type ZkClientContainer interface {
 	ZkClient() *ZookeeperClient
diff --git a/remoting/zookeeper/dataListener.go b/remoting/zookeeper/dataListener.go
deleted file mode 100644
index 4d3cb9efb..000000000
--- a/remoting/zookeeper/dataListener.go
+++ /dev/null
@@ -1,5 +0,0 @@
-package zookeeper
-
-type DataListener interface {
-	DataChange(eventType ZkEvent) bool //bool is return for interface implement is interesting
-}
diff --git a/remoting/zookeeper/listener.go b/remoting/zookeeper/listener.go
index c7ac45935..2fef2d8e0 100644
--- a/remoting/zookeeper/listener.go
+++ b/remoting/zookeeper/listener.go
@@ -25,15 +25,19 @@ import (
 )
 
 import (
-	"github.com/apache/dubbo-go/common/logger"
 	perrors "github.com/pkg/errors"
 	"github.com/samuel/go-zookeeper/zk"
 )
 
 import (
 	"github.com/apache/dubbo-go/common"
+	"github.com/apache/dubbo-go/common/logger"
 )
 
+type DataListener interface {
+	DataChange(eventType ZkEvent) bool //bool is return for interface implement is interesting
+}
+
 type ZkEvent struct {
 	Res *common.Event
 	err error
-- 
GitLab