code: func (b *Broadcaster) run() {
  	defer close(b.closed)
  	remove := func(target Sink) {
  		for i, sink := range b.sinks {
  			if sink == target {
  				b.sinks = append(b.sinks[:i], b.sinks[i+1:]...)
  				break
  			}
  		}
  	}
  
  	for {
  		select {
  		case event := <-b.events:
  			for _, sink := range b.sinks {
  				if err := sink.Write(event); err != nil {
  					if err == ErrSinkClosed {
  						// remove closed sinks
  						remove(sink)
  						continue
  					}
  					logrus.WithField("event", event).WithField("events.sink", sink).WithError(err).
  						Errorf("broadcaster: dropping event")
  				}
  			}
  		case request := <-b.adds:
  			// while we have to iterate for add/remove, common iteration for
  			// send is faster against slice.
  
  			var found bool
  			for _, sink := range b.sinks {
  				if request.sink == sink {
  					found = true
  					break
  				}
  			}
  
  			if !found {
  				b.sinks = append(b.sinks, request.sink)
  			}
  			// b.sinks[request.sink] = struct{}{}
  			request.response <- nil
  		case request := <-b.removes:
  			remove(request.sink)
  			request.response <- nil
  		case <-b.shutdown:
  			// close all the underlying sinks
  			for _, sink := range b.sinks {
  				if err := sink.Close(); err != nil && err != ErrSinkClosed {
  					logrus.WithField("events.sink", sink).WithError(err).
  						Errorf("broadcaster: closing sink failed")
  				}
  			}
  			return
  		}
  	}
  }
docs: // run is the main broadcast loop, started when the broadcaster is created.
  // Under normal conditions, it waits for events on the event channel. After
  // Close is called, this goroutine will exit.