mirror of https://github.com/go-redis/redis.git
Fix example
This commit is contained in:
parent
62fa0f88da
commit
480db94d33
|
@ -324,11 +324,17 @@ func ExamplePubSub() {
|
||||||
pubsub := client.Subscribe("mychannel1")
|
pubsub := client.Subscribe("mychannel1")
|
||||||
defer pubsub.Close()
|
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.
|
// Go channel which receives messages.
|
||||||
ch := pubsub.Channel()
|
ch := pubsub.Channel()
|
||||||
|
|
||||||
// Publish a message.
|
// Publish a message.
|
||||||
err := client.Publish("mychannel1", "hello").Err()
|
err = client.Publish("mychannel1", "hello").Err()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue