From 1a9fe28549e9cac1d163488887e9a24f4ef78936 Mon Sep 17 00:00:00 2001 From: shoopea Date: Wed, 15 May 2019 10:36:57 +0800 Subject: [PATCH] change var --- mq.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mq.go b/mq.go index 9b9222b..1b92e32 100644 --- a/mq.go +++ b/mq.go @@ -52,6 +52,7 @@ func MQSendMsgWorker(id int, msgs <-chan ChatWarsMessage) { } func MQReceiveMsgWorker(id int, cmd chan<- ChatWarsCommand) { + var c ChatWarsCommand conn, err := amqp.Dial("amqp://" + cfg.Rabbit.User + ":" + cfg.Rabbit.Password + "@" + cfg.Rabbit.Host + "/" + cfg.Rabbit.ReceiveQueue) failOnError(err, "MQReceiveMsgWorker["+strconv.Itoa(id)+"] : Failed to connect to RabbitMQ") defer conn.Close() @@ -83,10 +84,10 @@ func MQReceiveMsgWorker(id int, cmd chan<- ChatWarsCommand) { for d := range m { // log.Printf("MQReceiveMsgWorker["+strconv.Itoa(id)+"] : Received a message: %s", string(d.Body)) - err = json.Unmarshal(d.Body, &x) + err = json.Unmarshal(d.Body, &c) logOnError(err, "MQReceiveMsgWorker["+strconv.Itoa(id)+"] : Can't unmarshal.\n"+string(d.Body)) if err == nil { - cmd <- x + cmd <- c } }