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 09:56:25 UTC

[rocketmq-client-go] branch master updated: 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 master
in repository https://gitbox.apache.org/repos/asf/rocketmq-client-go.git


The following commit(s) were added to refs/heads/master by this push:
     new 2b0a3e8  fix(golint): fix warnings for golint check (#247)
2b0a3e8 is described below

commit 2b0a3e85a592308054c31e66da3c1e8364bb137f
Author: dinglei <li...@163.com>
AuthorDate: Tue Oct 15 17:56:16 2019 +0800

    fix(golint): fix warnings for golint check (#247)
    
    * fix(golint): fix warnings for golint check
---
 .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, 54 insertions(+), 17 deletions(-)

diff --git a/.gitignore b/.gitignore
index 485dee6..dff137a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
 .idea
+pkg
diff --git a/benchmark/consumer.go b/benchmark/consumer.go
index 1a893c9..73da836 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, seperated by comma")
+	flags.StringVar(&c.nameSrv, "n", "", "namesrv address list, separated 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 152deae..9bb69a5 100644
--- a/core/api.go
+++ b/core/api.go
@@ -14,14 +14,17 @@
  *  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
@@ -48,8 +51,10 @@ func (config *ClientConfig) String() string {
 	return str
 }
 
+//ProducerModel Common or orderly
 type ProducerModel int
 
+//Different models
 const (
 	CommonProducer  = ProducerModel(1)
 	OrderlyProducer = ProducerModel(2)
@@ -98,6 +103,7 @@ func (config *ProducerConfig) String() string {
 	return str + "]"
 }
 
+//Producer define interface
 type Producer interface {
 	baseAPI
 	// SendMessageSync send a message with sync
@@ -121,8 +127,10 @@ func NewPushConsumer(config *PushConsumerConfig) (PushConsumer, error) {
 	return newPushConsumer(config)
 }
 
+//MessageModel Clustering or BroadCasting
 type MessageModel int
 
+//MessageModel
 const (
 	BroadCasting = MessageModel(1)
 	Clustering   = MessageModel(2)
@@ -139,8 +147,10 @@ func (mode MessageModel) String() string {
 	}
 }
 
+//ConsumerModel CoCurrently or Orderly
 type ConsumerModel int
 
+//ConsumerModel
 const (
 	CoCurrently = ConsumerModel(1)
 	Orderly     = ConsumerModel(2)
@@ -198,6 +208,7 @@ func (config *PushConsumerConfig) String() string {
 	return str + "]"
 }
 
+// PushConsumer apis for PushConsumer
 type PushConsumer interface {
 	baseAPI
 
@@ -225,6 +236,7 @@ type PullConsumer interface {
 	FetchSubscriptionMessageQueues(topic string) []MessageQueue
 }
 
+//SessionCredentials access config for client
 type SessionCredentials struct {
 	AccessKey string
 	SecretKey string
@@ -236,6 +248,7 @@ 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 e21fbd4..4f17534 100644
--- a/core/cfuns.go
+++ b/core/cfuns.go
@@ -14,6 +14,7 @@
  *  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 6be7883..8986660 100644
--- a/core/error.go
+++ b/core/error.go
@@ -25,6 +25,7 @@ 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 e072bff..8c32847 100644
--- a/core/message.go
+++ b/core/message.go
@@ -14,6 +14,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
+
 package rocketmq
 
 /*
@@ -28,6 +29,7 @@ import (
 	"unsafe"
 )
 
+//Message used for send
 type Message struct {
 	Topic          string
 	Tags           string
@@ -71,6 +73,7 @@ func goMsgToC(gomsg *Message) *C.struct_CMessage {
 	return cmsg
 }
 
+//MessageExt used for consume
 type MessageExt struct {
 	Message
 	MessageID                 string
@@ -94,6 +97,7 @@ 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 03254b0..9c6901f 100644
--- a/core/producer.go
+++ b/core/producer.go
@@ -14,6 +14,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
+
 package rocketmq
 
 /*
@@ -37,12 +38,17 @@ import (
 	"unsafe"
 )
 
+//SendStatus The Status for send result from C apis.
 type SendStatus int
 
 const (
-	SendOK                = SendStatus(C.E_SEND_OK)
-	SendFlushDiskTimeout  = SendStatus(C.E_SEND_FLUSH_DISK_TIMEOUT)
+	//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
 	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 017a733..32e47f3 100644
--- a/core/push_consumer.go
+++ b/core/push_consumer.go
@@ -14,6 +14,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
+
 package rocketmq
 
 /*
@@ -39,10 +40,13 @@ 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)
 )
 
@@ -77,11 +81,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 7bf1927..306e5dc 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 e9f83f1..c2e94c3 100644
--- a/core/utils.go
+++ b/core/utils.go
@@ -14,6 +14,7 @@
  *  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 eacda1c..fd384db 100644
--- a/core/version.go
+++ b/core/version.go
@@ -14,10 +14,13 @@
  *  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 da65d98..cc457a6 100644
--- a/demos/orderly_push_consumer.go
+++ b/demos/orderly_push_consumer.go
@@ -39,9 +39,10 @@ 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 6664498..e379a93 100644
--- a/demos/producer_orderly.go
+++ b/demos/producer_orderly.go
@@ -14,6 +14,7 @@
  *  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 cf5feb0..98a1ddf 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 2334d45..9f361bc 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 9943f5b..f88c3d5 100644
--- a/examples/producer_orderly.go
+++ b/examples/producer_orderly.go
@@ -14,6 +14,7 @@
  *  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 1b209c0..de38048 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 38e434c..3f0e34a 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 {