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


Golang Client.RateLimits方法代碼示例

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


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

示例1: allIssuesInRepo

func allIssuesInRepo(client *github.Client, owner, repo string) []github.Issue {
	rate, _, err := client.RateLimits()
	if err != nil {
		fmt.Printf("error fetching rate limit (%v)\n", err)
	} else {
		fmt.Printf("API Rate Limit: %s\n", rate)
	}

	opt := &github.IssueListByRepoOptions{
		State: "all",
		ListOptions: github.ListOptions{
			PerPage: 100,
		},
	}
	var issues []github.Issue
	for i := 0; ; i++ {
		is, resp, err := client.Issues.ListByRepo(owner, repo, opt)
		if err != nil {
			fmt.Printf("error listing issues (%v)\n", err)
			os.Exit(1)
		}
		issues = append(issues, is...)
		if resp.NextPage == 0 {
			break
		}
		opt.ListOptions.Page = resp.NextPage
		fmt.Printf("list %d issues...\n", len(issues))
	}
	return issues
}
開發者ID:yichengq,項目名稱:issue-analyzer,代碼行數:30,代碼來源:context.go

示例2: simulateAPIRequest

func simulateAPIRequest(t *testing.T, c *gh.Client) []*http.Request {
	var requests []*http.Request
	mux := http.NewServeMux()
	mux.HandleFunc("/rate_limit", func(w http.ResponseWriter, req *http.Request) {
		requests = append(requests, req)
		w.Write([]byte("{}"))
	})

	srv := httptest.NewServer(mux)
	defer srv.Close()

	c.BaseURL, _ = url.Parse(srv.URL)
	if _, _, err := c.RateLimits(); err != nil {
		t.Fatalf("failed to retrieve rate limits; %v", err)
	}
	return requests
}
開發者ID:asemt,項目名稱:vossibility-collector,代碼行數:17,代碼來源:client_test.go


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