Exemple #1
0
// Dump github repository
func DumpRepository() {
	var allRepos []github.Repository

	ghClient, user := credential.GetGithubClient()
	opt := &github.RepositoryListOptions{
		ListOptions: github.ListOptions{PerPage: 100},
	}

	for {
		repos, response, err := ghClient.Repositories.List(user, opt)
		utils.Dieif(err)

		allRepos = append(allRepos, repos...)
		if response.NextPage == 0 {
			break
		} else {
			opt.ListOptions.Page = response.NextPage
		}
	}

	showResultRepository(allRepos)

	//fmt.Println(*repo.HTMLURL)
	//wg.Wait()
	//for _, repo := range allRepos {
	//	fmt.Println(*repo.HTMLURL)
	// TODO: goroutine
	//var wg sync.WaitGroup
	//count := 0
	//for {
	//	wg.Add(count)
	//	count += 1
	//	go func() {
	//		repos, response, err := ghClient.Repositories.List(user, opt)
	//		utils.Dieif(err)

	//		allRepos = append(allRepos, repos...)
	//		if response.NextPage == 0 {
	//			return
	//		} else {
	//			opt.ListOptions.Page = response.NextPage
	//		}
	//		wg.Done()
	//	}()
	//}
	//wg.Wait()
	//for _, repo := range allRepos {
	//	fmt.Println(*repo.HTMLURL)
	//}
}
Exemple #2
0
// Dump github starred repository
func DumpStarredRepository() {
	var allRepos []github.StarredRepository
	ghClient, user := credential.GetGithubClient()
	opt := &github.ActivityListStarredOptions{
		ListOptions: github.ListOptions{PerPage: 100},
	}

	// TODO: goroutine
	for {
		repos, response, err := ghClient.Activity.ListStarred(user, opt)
		utils.Dieif(err)

		allRepos = append(allRepos, repos...)
		if response.NextPage == 0 {
			break
		} else {
			opt.ListOptions.Page = response.NextPage
		}
	}

	showResultStarredRepository(allRepos)
}