func (p *FanOut) Run(callBack func(interface{}) error, data interface{}) {
	p.size <- true
	go func() {
		err := callBack(data)
		if err != nil {
			p.errChan <- err
		}
		<-p.size
	}()
}
Run a new routine with an optional data value
package syncutil
import "sync"
type FanOut struct {
	errChan chan error
	size    chan bool
	errs    []error
	wg      sync.WaitGroup
}
func NewFanOut(size int) *FanOut {
	if size == 0 {
		size = 1
	}
	pool := FanOut{
		errChan: make(chan error, size),
		size:    make(chan bool, size),
		errs:    make([]error, 0),
	}
	pool.start()
	return &pool
}
func (p *FanOut) start() {
	p.wg.Add(1)
	go func() {
		for {
			select {
			case err, ok := <-p.errChan:
				if !ok {
					p.wg.Done()
					return
				}
				p.errs = append(p.errs, err)
			}
		}
	}()
}