From eecd319ee3dd8306e8f015cc429b43e140eec06b Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Thu, 21 May 2020 09:10:43 +0300 Subject: [PATCH] Fix nil type assertion --- pubsub.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pubsub.go b/pubsub.go index e1164093..26cde242 100644 --- a/pubsub.go +++ b/pubsub.go @@ -309,9 +309,11 @@ func (c *PubSub) newMessage(reply interface{}) (interface{}, error) { case []interface{}: switch kind := reply[0].(string); kind { case "subscribe", "unsubscribe", "psubscribe", "punsubscribe": + // Can be nil in case of "unsubscribe". + channel, _ := reply[1].(string) return &Subscription{ Kind: kind, - Channel: reply[1].(string), + Channel: channel, Count: int(reply[2].(int64)), }, nil case "message":