本文整理匯總了Golang中github.com/octokit/go-octokit/octokit.Hyperlink.Expand方法的典型用法代碼示例。如果您正苦於以下問題:Golang Hyperlink.Expand方法的具體用法?Golang Hyperlink.Expand怎麽用?Golang Hyperlink.Expand使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/octokit/go-octokit/octokit.Hyperlink
的用法示例。
在下文中一共展示了Hyperlink.Expand方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: CreateRepository
func (client *Client) CreateRepository(project *Project, description, homepage string, isPrivate bool) (repo *octokit.Repository, err error) {
var repoURL octokit.Hyperlink
if project.Owner != client.Host.User {
repoURL = octokit.OrgRepositoriesURL
} else {
repoURL = octokit.UserRepositoriesURL
}
url, err := repoURL.Expand(octokit.M{"org": project.Owner})
if err != nil {
return
}
api, err := client.api()
if err != nil {
err = FormatError("creating repository", err)
return
}
params := octokit.Repository{
Name: project.Name,
Description: description,
Homepage: homepage,
Private: isPrivate,
}
repo, result := api.Repositories(client.requestURL(url)).Create(params)
if result.HasError() {
err = FormatError("creating repository", result.Err)
return
}
return
}
示例2: releaseRequest
func releaseRequest(owner, name, etag string, uri octokit.Hyperlink, output interface{}) (result *octokit.Result, respEtag string) {
params := repoParams(owner, name)
url, err := uri.Expand(params)
if err != nil {
return &octokit.Result{Err: err}, ""
}
result, respEtag = sendRequest(url, func(req *octokit.Request) (*octokit.Response, error) {
req.Header.Set(noneMatchKey, etag)
return req.Get(output)
})
return
}
示例3: expandURL
func (repo *GitHubRepository) expandURL(link octokit.Hyperlink, state, sort string) (*url.URL, error) {
queryParams := map[string]string{
"sort": sort,
"direction": "asc",
"state": state,
"per_page": "100",
}
u, err := link.Expand(octokit.M{"owner": repo.Owner, "repo": repo.Name})
if err != nil {
return nil, err
}
q := u.Query()
for k, v := range queryParams {
q.Set(k, v)
}
u.RawQuery = q.Encode()
return u, nil
}