本文整理匯總了Golang中github.com/google/go-github/github.ListOptions.Page方法的典型用法代碼示例。如果您正苦於以下問題:Golang ListOptions.Page方法的具體用法?Golang ListOptions.Page怎麽用?Golang ListOptions.Page使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/google/go-github/github.ListOptions
的用法示例。
在下文中一共展示了ListOptions.Page方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Teams
// Teams returns a list of all team membership for the GitHub account.
func (c *client) Teams(u *model.User) ([]*model.Team, error) {
client := c.newClientToken(u.Token)
opts := new(github.ListOptions)
opts.Page = 1
var teams []*model.Team
for opts.Page > 0 {
list, resp, err := client.Organizations.List("", opts)
if err != nil {
return nil, err
}
teams = append(teams, convertTeamList(list)...)
opts.Page = resp.NextPage
}
return teams, nil
}
示例2: GetOrgs
// GetOrgs is a helper function that returns a list of
// all orgs that a user belongs to.
func GetOrgs(client *github.Client) ([]github.Organization, error) {
var orgs []github.Organization
var opts = github.ListOptions{}
opts.Page = 1
for opts.Page > 0 {
list, resp, err := client.Organizations.List("", &opts)
if err != nil {
return nil, err
}
orgs = append(orgs, list...)
// increment the next page to retrieve
opts.Page = resp.NextPage
}
return orgs, nil
}
示例3: pages
func pages(inner func(*github.ListOptions) (*github.Response, error)) (*github.Response, error) {
options := github.ListOptions{}
for {
response, err := inner(&options)
if err != nil {
return response, err
}
if response.NextPage == 0 {
return response, nil
}
options.Page = response.NextPage
}
return nil, nil
}