func (cm *PubSub) Publish(id string, msg interface{}) int {
	if id == "" {
		return 0
	}
	cm.lock.Lock()
	defer cm.lock.Unlock()

	subscribers, ok := cm.subMap[id]
	if !ok {
		return 0
	}

	for subscriber := range subscribers {
		subscriber := subscriber
		go func() {
			subscriber <- msg
		}()
	}
	return len(subscribers)
}
// Publish - publishes a message to all subscribers of an id and returns
// the number of subscribers messaged
publishes a message to all subscribers of an id and returns
the number of subscribers messaged
// Publish - publishes a message to all subscribers of an id and returns // the number of subscribers messaged
func (cm *PubSub) Publish(id string, msg interface{}) int {
	if id == "" {
		return 0
	}
	cm.lock.Lock()
	defer cm.lock.Unlock()
	subscribers, ok := cm.subMap[id]
	if !ok {
		return 0
	}
	for subscriber := range subscribers {
		subscriber := subscriber
		go func() {
			subscriber <- msg
		}()
	}
	return len(subscribers)
}
func ( cm * PubSub ) Publish ( id string , msg interface { } ) int { if id == " " { return 0 } cm . lock . Lock ( ) defer cm . lock . Unlock ( ) subscribers , ok := cm . subMap [ id ] if ! ok { return 0 } for subscriber := range subscribers { subscriber := subscriber go func ( ) { subscriber <- msg } ( ) } return len ( subscribers ) }
publishes a message to all subscribers of an id and returns
the number of subscribers messaged
publishes a message to all subscribers of an id and returns the number of subscribers messaged