Merge PMessage and Message
diff --git a/redis/pubsub.go b/redis/pubsub.go
index f0ac825..2da6021 100644
--- a/redis/pubsub.go
+++ b/redis/pubsub.go
@@ -36,18 +36,9 @@
// The originating channel.
Channel string
- // The message data.
- Data []byte
-}
-
-// PMessage represents a pmessage notification.
-type PMessage struct {
- // The matched pattern.
+ // The matched pattern, if any
Pattern string
- // The originating channel.
- Channel string
-
// The message data.
Data []byte
}
@@ -102,9 +93,9 @@
return c.Conn.Flush()
}
-// Receive returns a pushed message as a Subscription, Message, PMessage, Pong
-// or error. The return value is intended to be used directly in a type switch
-// as illustrated in the PubSubConn example.
+// Receive returns a pushed message as a Subscription, Message, Pong or error.
+// The return value is intended to be used directly in a type switch as
+// illustrated in the PubSubConn example.
func (c PubSubConn) Receive() interface{} {
return c.receiveInternal(c.Conn.Receive())
}
@@ -135,11 +126,11 @@
}
return m
case "pmessage":
- var pm PMessage
- if _, err := Scan(reply, &pm.Pattern, &pm.Channel, &pm.Data); err != nil {
+ var m Message
+ if _, err := Scan(reply, &m.Pattern, &m.Channel, &m.Data); err != nil {
return err
}
- return pm
+ return m
case "subscribe", "psubscribe", "unsubscribe", "punsubscribe":
s := Subscription{Kind: kind}
if _, err := Scan(reply, &s.Channel, &s.Count); err != nil {