本文整理匯總了Golang中github.com/google/go-github/github.Client.NewRequest方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.NewRequest方法的具體用法?Golang Client.NewRequest怎麽用?Golang Client.NewRequest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/google/go-github/github.Client
的用法示例。
在下文中一共展示了Client.NewRequest方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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
}
示例2: 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
}
示例3: 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
}
示例4: 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
}
示例5: 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
}