func (b *Broker) Subscribe() chan interface{} {
	msgCh := make(chan interface{}, 64)
	b.subCh <- msgCh
	return msgCh
}
Subscribe returns a new channel for a receiver.
package main
import "log"
type Broker struct {
	stopCh    chan struct{}
	publishCh chan interface{}
	subCh     chan chan interface{}
	unsubCh   chan chan interface{}
}
func NewBroker() *Broker {
	return &Broker{
		stopCh:    make(chan struct{}),
		publishCh: make(chan interface{}, 64),
		subCh:     make(chan chan interface{}),
		unsubCh:   make(chan chan interface{}),
	}
}
func (b *Broker) Start() {
	subs := map[chan interface{}]struct{}{}
	for {
		select {
		case <-b.stopCh:
			for msgCh := range subs {
				close(msgCh)
			}
			return
		case msgCh := <-b.subCh:
			subs[msgCh] = struct{}{}
		case msgCh := <-b.unsubCh:
			delete(subs, msgCh)
		case msg := <-b.publishCh:
			for msgCh := range subs {
				select {
				case msgCh <- msg:
				default:
					log.Print("Client is stuck - message ignored")
				}
			}
		}
	}
}
func (b *Broker) Stop() {
	close(b.stopCh)
}