code: func (d *Downloader) spawnSync(fetchers []func() error) error {
  	errc := make(chan error, len(fetchers))
  	d.cancelWg.Add(len(fetchers))
  	for _, fn := range fetchers {
  		fn := fn
  		go func() { defer d.cancelWg.Done(); errc <- fn() }()
  	}
  	// Wait for the first error, then terminate the others.
  	var err error
  	for i := 0; i < len(fetchers); i++ {
  		if i == len(fetchers)-1 {
  			// Close the queue when all fetchers have exited.
  			// This will cause the block processor to end when
  			// it has processed the queue.
  			d.queue.Close()
  		}
  		if err = <-errc; err != nil {
  			break
  		}
  	}
  	d.queue.Close()
  	d.Cancel()
  	return err
  }
docs: // spawnSync runs d.process and all given fetcher functions to completion in
  // separate goroutines, returning the first error that appears.