當前位置: 首頁>>代碼示例>>Golang>>正文


Golang IssueListByRepoOptions.ListOptions方法代碼示例

本文整理匯總了Golang中github.com/google/go-github/github.IssueListByRepoOptions.ListOptions方法的典型用法代碼示例。如果您正苦於以下問題:Golang IssueListByRepoOptions.ListOptions方法的具體用法?Golang IssueListByRepoOptions.ListOptions怎麽用?Golang IssueListByRepoOptions.ListOptions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/google/go-github/github.IssueListByRepoOptions的用法示例。


在下文中一共展示了IssueListByRepoOptions.ListOptions方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: ListAllIssues

// ListAllIssues grabs all issues matching the options, so you don't have to
// worry about paging. Enforces some constraints, like min/max PR number and
// having a valid user.
func (config *Config) ListAllIssues(listOpts *github.IssueListByRepoOptions) ([]*github.Issue, error) {
	allIssues := []*github.Issue{}
	page := 1
	for {
		glog.V(4).Infof("Fetching page %d of issues", page)
		listOpts.ListOptions = github.ListOptions{PerPage: 100, Page: page}
		issues, response, err := config.client.Issues.ListByRepo(config.Org, config.Project, listOpts)
		config.analytics.ListIssues.Call(config, response)
		if err != nil {
			return nil, err
		}
		for i := range issues {
			issue := &issues[i]
			if issue.Number == nil {
				glog.Infof("Skipping issue with no number, very strange")
				continue
			}
			if issue.User == nil || issue.User.Login == nil {
				glog.V(2).Infof("Skipping PR %d with no user info %#v.", *issue.Number, issue.User)
				continue
			}
			if *issue.Number < config.MinPRNumber {
				glog.V(6).Infof("Dropping %d < %d", *issue.Number, config.MinPRNumber)
				continue
			}
			if *issue.Number > config.MaxPRNumber {
				glog.V(6).Infof("Dropping %d > %d", *issue.Number, config.MaxPRNumber)
				continue
			}
			allIssues = append(allIssues, issue)
		}
		if response.LastPage == 0 || response.LastPage <= page {
			break
		}
		page++
	}
	return allIssues, nil
}
開發者ID:timstclair,項目名稱:kube-contrib,代碼行數:41,代碼來源:github.go


注:本文中的github.com/google/go-github/github.IssueListByRepoOptions.ListOptions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。