func (m *Messenger) Kill() {
	select {
	case <-m.killed:
	case m.kill <- struct{}{}:
	}
}
Kill closes and removes all clients
and stops the monitor() goroutine of Messenger,
making the Messenger instance unusable.
Kill should only be called when all clients have exited.
package messenger
import (
	"fmt"
)
type Messenger struct {
	buffer    int
	drop      bool
	get       chan chan interface{}
	del       chan chan interface{}
	broadcast chan interface{}
	pool      map[chan interface{}]struct{}
	reset     chan struct{}
	kill      chan struct{}
	killed    chan struct{}
	len       chan int
	blocked   chan interface{}  
	chanlens  chan []int        
}
func New(buffer uint, drop bool) *Messenger {
	m := setup(buffer, drop)
	go m.monitor()
	return m
}
func setup(buffer uint, drop bool) *Messenger {
	m := &Messenger{
		buffer:    int(buffer),
		drop:      drop,
		get:       make(chan chan interface{}),
		del:       make(chan chan interface{}),
		broadcast: make(chan interface{}),
		pool:      make(map[chan interface{}]struct{}),
		reset:     make(chan struct{}),
		kill:      make(chan struct{}),
		killed:    make(chan struct{}),
		len:       make(chan int),
	}
	if buffer == 0 {
		m.drop = false
	}
	return m
}
func newNoMonitor(buffer uint, drop bool) *Messenger {
	return setup(buffer, drop)
}
func (m *Messenger) monitor() {
	client := make(chan interface{}, m.buffer)
	for {
		select {
		case <-m.len:
			m.len <- len(m.pool)
		case m.get <- client:
			m.pool[client] = struct{}{}
			client = make(chan interface{}, m.buffer)
		case client := <-m.del:
			if _, ok := m.pool[client]; ok {
				close(client)
				delete(m.pool, client)
			}
		case <-m.reset:
			for client := range m.pool {
				close(client)
				delete(m.pool, client)
			}
		case <-m.kill:
			for client := range m.pool {
				close(client)
				delete(m.pool, client)
			}
			close(m.killed)
			return
		case msg := <-m.broadcast:
			for client := range m.pool {
				if m.drop && m.buffer != 0 && len(client) == m.buffer {
					continue
				}
				select {
				case client <- msg:
				case m.blocked <- msg:  
				}
			}
		case m.chanlens <- m.getlens():  
		}
	}
}
func (m *Messenger) getlens() (l []int) {
	for k := range m.pool {
		l = append(l, len(k))
	}
	return
}
func (m *Messenger) Reset() {
	select {
	case <-m.killed:
	case m.reset <- struct{}{}:
	}
}