title: Golang: Can I cast to chan interface{}
body: <p>I am trying to write a general purpose wrapper for subscriptions, something like:</p>
  
  <pre><code>type Subscriber interface{
      Subscribe(addr string) chan interface{}
  }
  </code></pre>
  
  <p>Suppose there is a library I want to use which has a subscribe method in it, but which uses a <code>chan library.Object</code>. I would like to be able to do something like:</p>
  
  <pre><code>func (s *mySubscriber) Subscribe(addr string) chan interface{}{
      ch := make(chan library.Object)
      library.Subscribe(addr, ch)
      return chan interface{}(ch)
  }
  </code></pre>
  
  <p>Currently, I don't believe such a cast is possible. And I don't want to modify the underlying library, since the wrapper should be agnostic to library implementations.</p>
  
  <p>I've seen <a href="https://stackoverflow.com/questions/13425490/is-there-a-way-to-cast-structs-for-sending-over-a-channel">Is there a way to cast Structs for sending over a channel</a>, but in that case the application can be modified to suit the need. Here, it can't. Is this possible? Is there a better way?</p>
  
  <p>One solution is to pass in a general purpose channel into Subscribe, and to wait indefinetely on <code>chan library.Object</code> and fire anything that comes through on my general channel, but I didn't particularly like having to introduce another channel just to get around the type cast.</p>