title: How to write better Receive() in Golang for Redis(redigo) Pubsub?
body: <pre><code>psc := redis.PubSubConn{c}
  psc.Subscribe("example")
  
  func Receive() {
      for {
          switch v := psc.Receive().(type) {
          case redis.Message:
              fmt.Printf("%s: message: %s\n", v.Channel, v.Data)
          case redis.Subscription:
              fmt.Printf("%s: %s %d\n", v.Channel, v.Kind, v.Count)
          case error:
              return v
          }
      }
  }
  </code></pre>
  
  <p>In the above code(taken from <a href="https://godoc.org/github.com/garyburd/redigo/redis" rel="nofollow">Redigo doc</a>), if connection is lost, all subscriptions are also lost. What will be better way to recover from lost connection and resubscribe.</p>