You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by di...@apache.org on 2019/10/15 10:21:50 UTC

[rocketmq-client-go] 01/01: Revert "fix(golint): fix warnings for golint check (#247)"

This is an automated email from the ASF dual-hosted git repository.

dinglei pushed a commit to branch revert-247-golint
in repository https://gitbox.apache.org/repos/asf/rocketmq-client-go.git

commit 492f0b257cf10fadbfa59046f1dad9f29d61ac2b
Author: dinglei <li...@163.com>
AuthorDate: Tue Oct 15 18:21:37 2019 +0800

    Revert "fix(golint): fix warnings for golint check (#247)"
    
    This reverts commit 2b0a3e85a592308054c31e66da3c1e8364bb137f.
---
 .gitignore                     |  1 -
 benchmark/consumer.go          |  2 +-
 core/api.go                    | 13 -------------
 core/cfuns.go                  |  1 -
 core/error.go                  |  1 -
 core/message.go                |  4 ----
 core/producer.go               | 10 ++--------
 core/push_consumer.go          |  8 ++------
 core/queue_selector.go         |  2 +-
 core/utils.go                  |  1 -
 core/version.go                |  3 ---
 demos/orderly_push_consumer.go |  5 ++---
 demos/producer_orderly.go      |  1 -
 demos/push_consumer.go         |  4 ++--
 examples/main.go               | 10 +++++-----
 examples/producer_orderly.go   |  1 -
 examples/pull_consumer.go      |  2 +-
 examples/push_consumer.go      |  2 +-
 18 files changed, 17 insertions(+), 54 deletions(-)

diff --git a/.gitignore b/.gitignore
index dff137a..485dee6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1 @@
 .idea
-pkg
diff --git a/benchmark/consumer.go b/benchmark/consumer.go
index 73da836..1a893c9 100644
--- a/benchmark/consumer.go
+++ b/benchmark/consumer.go
@@ -115,7 +115,7 @@ func init() {
 
 	flags.StringVar(&c.topic, "t", "BenchmarkTest", "topic")
 	flags.StringVar(&c.groupPrefix, "g", "benchmark_consumer", "group prefix")
-	flags.StringVar(&c.nameSrv, "n", "", "namesrv address list, separated by comma")
+	flags.StringVar(&c.nameSrv, "n", "", "namesrv address list, seperated by comma")
 	flags.BoolVar(&c.isPrefixEnable, "p", true, "group prefix is enable")
 	flags.StringVar(&c.filterType, "f", "", "filter type,options:TAG|SQL92, or empty")
 	flags.StringVar(&c.expression, "e", "*", "expression")
diff --git a/core/api.go b/core/api.go
index 9bb69a5..152deae 100644
--- a/core/api.go
+++ b/core/api.go
@@ -14,17 +14,14 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 package rocketmq
 
 import "fmt"
 
-//Version get go sdk version
 func Version() (version string) {
 	return GetVersion()
 }
 
-//ClientConfig save client config
 type ClientConfig struct {
 	GroupID          string
 	NameServer       string
@@ -51,10 +48,8 @@ func (config *ClientConfig) String() string {
 	return str
 }
 
-//ProducerModel Common or orderly
 type ProducerModel int
 
-//Different models
 const (
 	CommonProducer  = ProducerModel(1)
 	OrderlyProducer = ProducerModel(2)
@@ -103,7 +98,6 @@ func (config *ProducerConfig) String() string {
 	return str + "]"
 }
 
-//Producer define interface
 type Producer interface {
 	baseAPI
 	// SendMessageSync send a message with sync
@@ -127,10 +121,8 @@ func NewPushConsumer(config *PushConsumerConfig) (PushConsumer, error) {
 	return newPushConsumer(config)
 }
 
-//MessageModel Clustering or BroadCasting
 type MessageModel int
 
-//MessageModel
 const (
 	BroadCasting = MessageModel(1)
 	Clustering   = MessageModel(2)
@@ -147,10 +139,8 @@ func (mode MessageModel) String() string {
 	}
 }
 
-//ConsumerModel CoCurrently or Orderly
 type ConsumerModel int
 
-//ConsumerModel
 const (
 	CoCurrently = ConsumerModel(1)
 	Orderly     = ConsumerModel(2)
@@ -208,7 +198,6 @@ func (config *PushConsumerConfig) String() string {
 	return str + "]"
 }
 
-// PushConsumer apis for PushConsumer
 type PushConsumer interface {
 	baseAPI
 
@@ -236,7 +225,6 @@ type PullConsumer interface {
 	FetchSubscriptionMessageQueues(topic string) []MessageQueue
 }
 
-//SessionCredentials access config for client
 type SessionCredentials struct {
 	AccessKey string
 	SecretKey string
@@ -248,7 +236,6 @@ func (session *SessionCredentials) String() string {
 		session.AccessKey, session.SecretKey, session.Channel)
 }
 
-//SendResult status for send
 type SendResult struct {
 	Status SendStatus
 	MsgId  string
diff --git a/core/cfuns.go b/core/cfuns.go
index 4f17534..e21fbd4 100644
--- a/core/cfuns.go
+++ b/core/cfuns.go
@@ -14,7 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 package rocketmq
 
 /*
diff --git a/core/error.go b/core/error.go
index 8986660..6be7883 100644
--- a/core/error.go
+++ b/core/error.go
@@ -25,7 +25,6 @@ import "fmt"
 
 type rmqError int
 
-//This is error messages
 const (
 	NIL                        = rmqError(C.OK)
 	ErrNullPoint               = rmqError(C.NULL_POINTER)
diff --git a/core/message.go b/core/message.go
index 8c32847..e072bff 100644
--- a/core/message.go
+++ b/core/message.go
@@ -14,7 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 package rocketmq
 
 /*
@@ -29,7 +28,6 @@ import (
 	"unsafe"
 )
 
-//Message used for send
 type Message struct {
 	Topic          string
 	Tags           string
@@ -73,7 +71,6 @@ func goMsgToC(gomsg *Message) *C.struct_CMessage {
 	return cmsg
 }
 
-//MessageExt used for consume
 type MessageExt struct {
 	Message
 	MessageID                 string
@@ -97,7 +94,6 @@ func (msgExt *MessageExt) String() string {
 		msgExt.StoreTimestamp, msgExt.QueueOffset, msgExt.CommitLogOffset, msgExt.PreparedTransactionOffset)
 }
 
-//GetProperty get the message property by key from message ext
 func (msgExt *MessageExt) GetProperty(key string) string {
 	return C.GoString(C.GetMessageProperty(msgExt.cmsgExt, C.CString(key)))
 }
diff --git a/core/producer.go b/core/producer.go
index 9c6901f..03254b0 100644
--- a/core/producer.go
+++ b/core/producer.go
@@ -14,7 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 package rocketmq
 
 /*
@@ -38,17 +37,12 @@ import (
 	"unsafe"
 )
 
-//SendStatus The Status for send result from C apis.
 type SendStatus int
 
 const (
-	//SendOK OK
-	SendOK = SendStatus(C.E_SEND_OK)
-	//SendFlushDiskTimeout Failed because broker flush error
-	SendFlushDiskTimeout = SendStatus(C.E_SEND_FLUSH_DISK_TIMEOUT)
-	//SendFlushSlaveTimeout Failed because slave broker timeout
+	SendOK                = SendStatus(C.E_SEND_OK)
+	SendFlushDiskTimeout  = SendStatus(C.E_SEND_FLUSH_DISK_TIMEOUT)
 	SendFlushSlaveTimeout = SendStatus(C.E_SEND_FLUSH_SLAVE_TIMEOUT)
-	//SendSlaveNotAvailable Failed because slave broker error
 	SendSlaveNotAvailable = SendStatus(C.E_SEND_SLAVE_NOT_AVAILABLE)
 )
 
diff --git a/core/push_consumer.go b/core/push_consumer.go
index 32e47f3..017a733 100644
--- a/core/push_consumer.go
+++ b/core/push_consumer.go
@@ -14,7 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 package rocketmq
 
 /*
@@ -40,13 +39,10 @@ import (
 	"unsafe"
 )
 
-//ConsumeStatus the retern value for consumer
 type ConsumeStatus int
 
 const (
-	//ConsumeSuccess commit offset to broker
 	ConsumeSuccess = ConsumeStatus(C.E_CONSUME_SUCCESS)
-	//ReConsumeLater it will be send back to broker
 	ReConsumeLater = ConsumeStatus(C.E_RECONSUME_LATER)
 )
 
@@ -81,11 +77,11 @@ func newPushConsumer(config *PushConsumerConfig) (PushConsumer, error) {
 		return nil, errors.New("config is nil")
 	}
 	if config.GroupID == "" {
-		return nil, errors.New("GroupId is empty")
+		return nil, errors.New("GroupId is empty.")
 	}
 
 	if config.NameServer == "" && config.NameServerDomain == "" {
-		return nil, errors.New("NameServer and NameServerDomain is empty")
+		return nil, errors.New("NameServer and NameServerDomain is empty.")
 	}
 
 	consumer := &defaultPushConsumer{config: config}
diff --git a/core/queue_selector.go b/core/queue_selector.go
index 306e5dc..7bf1927 100644
--- a/core/queue_selector.go
+++ b/core/queue_selector.go
@@ -14,9 +14,9 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 package rocketmq
 
+import "C"
 import (
 	"strconv"
 	"sync"
diff --git a/core/utils.go b/core/utils.go
index c2e94c3..e9f83f1 100644
--- a/core/utils.go
+++ b/core/utils.go
@@ -14,7 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 package rocketmq
 
 import "fmt"
diff --git a/core/version.go b/core/version.go
index fd384db..eacda1c 100644
--- a/core/version.go
+++ b/core/version.go
@@ -14,13 +14,10 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 package rocketmq
 
-//GoClientVersion const strings for version
 const GoClientVersion = "Go Client V1.2.4, Support CPP Core:V1.2.X"
 
-//GetVersion return go version strings
 func GetVersion() (version string) {
 	return GoClientVersion
 }
diff --git a/demos/orderly_push_consumer.go b/demos/orderly_push_consumer.go
index cc457a6..da65d98 100644
--- a/demos/orderly_push_consumer.go
+++ b/demos/orderly_push_consumer.go
@@ -39,10 +39,9 @@ func main3() {
 		Model:         rocketmq.Clustering,
 		ConsumerModel: rocketmq.Orderly,
 	}
-	consumeWithOrderly(pConfig)
+	ConsumeWithOrderly(pConfig)
 }
-
-func consumeWithOrderly(config *rocketmq.PushConsumerConfig) {
+func ConsumeWithOrderly(config *rocketmq.PushConsumerConfig) {
 
 	consumer, err := rocketmq.NewPushConsumer(config)
 	if err != nil {
diff --git a/demos/producer_orderly.go b/demos/producer_orderly.go
index e379a93..6664498 100644
--- a/demos/producer_orderly.go
+++ b/demos/producer_orderly.go
@@ -14,7 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 package main
 
 import (
diff --git a/demos/push_consumer.go b/demos/push_consumer.go
index 98a1ddf..cf5feb0 100644
--- a/demos/push_consumer.go
+++ b/demos/push_consumer.go
@@ -38,9 +38,9 @@ func main1() {
 		Model:         rocketmq.Clustering,
 		ConsumerModel: rocketmq.CoCurrently,
 	}
-	consumeWithPush(pConfig)
+	ConsumeWithPush(pConfig)
 }
-func consumeWithPush(config *rocketmq.PushConsumerConfig) {
+func ConsumeWithPush(config *rocketmq.PushConsumerConfig) {
 
 	consumer, err := rocketmq.NewPushConsumer(config)
 	if err != nil {
diff --git a/examples/main.go b/examples/main.go
index 9f361bc..2334d45 100644
--- a/examples/main.go
+++ b/examples/main.go
@@ -44,11 +44,11 @@ func main() {
 		pConfig := &rocketmq.ProducerConfig{ClientConfig: rocketmq.ClientConfig{
 			GroupID:    "MQ_INST_xxxxxxx%GID",
 			NameServer: "http://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:80",
-			Credentials: &rocketmq.SessionCredentials{
-				AccessKey: "xxxxxx",
-				SecretKey: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
-				Channel:   "mq-channel",
-			},
+             Credentials:&rocketmq.SessionCredentials{
+                 AccessKey:"xxxxxx",
+                 SecretKey:"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
+                 Channel:"mq-channel",
+            },
 			LogC: &rocketmq.LogConfig{
 				Path:     "example",
 				FileSize: 64 * 1 << 10,
diff --git a/examples/producer_orderly.go b/examples/producer_orderly.go
index f88c3d5..9943f5b 100644
--- a/examples/producer_orderly.go
+++ b/examples/producer_orderly.go
@@ -14,7 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 package main
 
 import (
diff --git a/examples/pull_consumer.go b/examples/pull_consumer.go
index de38048..1b209c0 100644
--- a/examples/pull_consumer.go
+++ b/examples/pull_consumer.go
@@ -24,7 +24,7 @@ import (
 	"github.com/apache/rocketmq-client-go/core"
 )
 
-func consumeWithPull(config *rocketmq.PullConsumerConfig, topic string) {
+func ConsumeWithPull(config *rocketmq.PullConsumerConfig, topic string) {
 
 	consumer, err := rocketmq.NewPullConsumer(config)
 	if err != nil {
diff --git a/examples/push_consumer.go b/examples/push_consumer.go
index 3f0e34a..38e434c 100644
--- a/examples/push_consumer.go
+++ b/examples/push_consumer.go
@@ -23,7 +23,7 @@ import (
 	"sync/atomic"
 )
 
-func consumeWithPush(config *rocketmq.PushConsumerConfig) {
+func ConsumeWithPush(config *rocketmq.PushConsumerConfig) {
 
 	consumer, err := rocketmq.NewPushConsumer(config)
 	if err != nil {