1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-22 10:01:50 +03:00

Fix example

This commit is contained in:
Vladimir Mihailenco
2018-07-24 10:48:14 +03:00
parent 62fa0f88da
commit 480db94d33

View File

@ -324,11 +324,17 @@ func ExamplePubSub() {
pubsub := client.Subscribe("mychannel1")
defer pubsub.Close()
// Wait for confirmation that subscription is created before publishing anything.
_, err := pubsub.Receive()
if err != nil {
panic(err)
}
// Go channel which receives messages.
ch := pubsub.Channel()
// Publish a message.
err := client.Publish("mychannel1", "hello").Err()
err = client.Publish("mychannel1", "hello").Err()
if err != nil {
panic(err)
}