func (p *GitHubProvider) Gather(user string) ([]GitRepository, error) {
	log.Debugf("Gathering repositories for Github org %s\n", user)

	wg := sync.WaitGroup{}

	var mu sync.Mutex

	// repositories protected by mu, since multiple goroutines will access it
	repositories := make([]GitRepository, 0)

	for pageCount := 1; pageCount <= p.totalPages; pageCount++ {
		wg.Add(1)

		go func(page int) {
			defer wg.Done()

			pageRepositories, err := p.gatherPage(user, page)
			if err != nil {
				log.Errorf("Error gathering page %v:%v\n", page, err)

				return
			}

			mu.Lock()
			repositories = append(repositories, pageRepositories...)
			mu.Unlock()
		}(pageCount)

		if pageCount == 1 {
			wg.Wait()

			if p.totalPages == unknownTotal {
				return nil, fmt.Errorf("unable to gather total pages")
			}
		}
	}

	wg.Wait()

	return repositories, nil
}
// Gather gather user's git repositories and send them to outputChannel.
Gather gather user's git repositories and send them to outputChannel.
// Gather gather user ' s git repositories and send them to outputChannel .
func (p *GitHubProvider) Gather(user string) ([]GitRepository, error) {
	log.Debugf("Gathering repositories for Github org %s\n", user)
	wg := sync.WaitGroup{}
	var mu sync.Mutex
	repositories := make([]GitRepository, 0)
	for pageCount := 1; pageCount <= p.totalPages; pageCount++ {
		wg.Add(1)
		go func(page int) {
			defer wg.Done()
			pageRepositories, err := p.gatherPage(user, page)
			if err != nil {
				log.Errorf("Error gathering page %v:%v\n", page, err)
				return
			}
			mu.Lock()
			repositories = append(repositories, pageRepositories...)
			mu.Unlock()
		}(pageCount)
		if pageCount == 1 {
			wg.Wait()
			if p.totalPages == unknownTotal {
				return nil, fmt.Errorf("unable to gather total pages")
			}
		}
	}
	wg.Wait()
	return repositories, nil
}
func ( p * GitHubProvider ) Gather ( user string ) ( [ ] GitRepository , error ) { log . Debugf ( " \n " , user ) wg := sync . WaitGroup { } var mu sync . Mutex repositories := make ( [ ] GitRepository , 0 ) for pageCount := 1 ; pageCount <= p . totalPages ; pageCount ++ { wg . Add ( 1 ) go func ( page int ) { defer wg . Done ( ) pageRepositories , err := p . gatherPage ( user , page ) if err != nil { log . Errorf ( " \n " , page , err ) return } mu . Lock ( ) repositories = append ( repositories , pageRepositories ... ) mu . Unlock ( ) } ( pageCount ) if pageCount == 1 { wg . Wait ( ) if p . totalPages == unknownTotal { return nil , fmt . Errorf ( " " ) } } } wg . Wait ( ) return repositories , nil }
Gather gather user's git repositories and send them to outputChannel.
Gather gather user ' s git repositories and send them to outputChannel .
// repositories protected by mu, since multiple goroutines will access it