• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang github.Client类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/google/go-github/github.Client的典型用法代码示例。如果您正苦于以下问题:Golang Client类的具体用法?Golang Client怎么用?Golang Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Client类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: printRateLimit

func printRateLimit(client github.Client) {
	rate, _, err := client.RateLimit()
	if err != nil {
		fmt.Println("Error fetching rate limit:", err)
	} else {
		remaining := int(rate.Reset.Sub(time.Now()).Seconds())
		mins := remaining / 60
		secs := remaining % 60
		fmt.Printf("API Rate Limit: %d/%d remaining for %dm %ds \n\n", rate.Remaining, rate.Limit, mins, secs)
	}
}
开发者ID:harryw,项目名称:github-pr-checker,代码行数:11,代码来源:github-pr-checker.go


示例3: AsciiCat

func AsciiCat(cl *github.Client) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		msg := "Hello, Go In 5 Minutes Viewer!"
		cat, _, err := cl.Octocat(msg)
		if err != nil {
			jsonErr(w, http.StatusInternalServerError, err)
			return
		}
		w.WriteHeader(http.StatusOK)
		w.Write([]byte(cat))
	})
}
开发者ID:choirudin2210,项目名称:go-in-5-minutes,代码行数:12,代码来源:ascii_cat.go


示例4: exceededRateLimit

func exceededRateLimit(client *github.Client) bool {
	rate, _, err := client.RateLimit()
	if err != nil {
		fmt.Printf("Error checking rate limit: %s\n", err)
		return false
	}
	// Check for a margin sufficient to run both examples.
	if rate.Remaining < 4 {
		fmt.Printf("Exceeded (or almost exceeded) GitHub API rate limit: %s. Try again later.\n", rate)
		return true
	}
	return false
}
开发者ID:jbenet,项目名称:apiproxy,代码行数:13,代码来源:client_test.go


示例5: GetHookSchema

func GetHookSchema(c *github.Client, name string) (*HookSchema, *github.Response, error) {
	req, err := c.NewRequest("GET", fmt.Sprintf("hooks/%v", name), nil)
	if err != nil {
		return nil, nil, err
	}
	hookSchema := new(HookSchema)
	resp, err := c.Do(req, hookSchema)
	if err != nil {
		return nil, resp, err
	}

	return hookSchema, resp, err
}
开发者ID:soh335,项目名称:ghh,代码行数:13,代码来源:hook_schema.go


示例6: GetHookSchemas

func GetHookSchemas(c *github.Client) ([]HookSchema, *github.Response, error) {
	req, err := c.NewRequest("GET", "hooks", nil)
	if err != nil {
		return nil, nil, err
	}
	hookSchemas := new([]HookSchema)
	resp, err := c.Do(req, hookSchemas)
	if err != nil {
		return nil, resp, err
	}

	return *hookSchemas, resp, err
}
开发者ID:soh335,项目名称:ghh,代码行数:13,代码来源:hook_schema.go


示例7: GitCommitStatuses

func GitCommitStatuses(client *github.Client, owner, repo, sha string) (interface{}, *github.Response, error) {

	u := fmt.Sprintf("repos/%v/%v/commits/%v/statuses", owner, repo, sha)
	req, err := client.NewRequest("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	var c interface{}
	resp, err := client.Do(req, &c)
	if err != nil {
		return nil, resp, err
	}
	return c, resp, err
}
开发者ID:astronoka,项目名称:gh,代码行数:15,代码来源:main.go


示例8: 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


示例9: PutGitCommitStatus

func PutGitCommitStatus(client *github.Client, owner, repo, sha string, body *CommitStatus) (interface{}, *github.Response, error) {

	u := fmt.Sprintf("repos/%v/%v/statuses/%v", owner, repo, sha)

	if body == nil {
		body = &CommitStatus{}
	}

	req, err := client.NewRequest("POST", u, body)
	if err != nil {
		return nil, nil, err
	}

	var c interface{}
	resp, err := client.Do(req, c)
	if err != nil {
		return nil, resp, err
	}

	return c, resp, err
}
开发者ID:astronoka,项目名称:gh,代码行数:21,代码来源:main.go


示例10: DownloadAsset

func DownloadAsset(client *github.Client, asset *github.ReleaseAsset) error {
	req, _ := client.NewRequest("GET", *asset.URL, nil)
	req.Header.Set("Accept", "application/octet-stream")

	apiResponse, err := client.Do(req, nil)

	assetResponse, err := http.Get(apiResponse.Response.Request.URL.String())

	if err != nil {
		return err
	}

	f, err := os.Create(flags.Output)

	if err != nil {
		return err
	}

	defer f.Close()
	io.Copy(f, assetResponse.Body)

	return nil
}
开发者ID:upfluence,项目名称:gh-downloader,代码行数:23,代码来源:main.go



注:本文中的github.com/google/go-github/github.Client类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang github.CombinedStatus类代码示例发布时间:2022-05-23
下一篇:
Golang github.BasicAuthTransport类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap