本文整理汇总了Golang中github.com/google/go-github/github.Issue.Number方法的典型用法代码示例。如果您正苦于以下问题:Golang Issue.Number方法的具体用法?Golang Issue.Number怎么用?Golang Issue.Number使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/google/go-github/github.Issue
的用法示例。
在下文中一共展示了Issue.Number方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: bulkWriteIssue
func bulkWriteIssue(old *github.Issue, updated []byte, status func(string)) (ids []int, err error) {
i := bytes.Index(updated, []byte(bulkHeader))
if i < 0 {
return nil, fmt.Errorf("cannot find bulk edit issue list")
}
ids = readBulkIDs(updated[i:])
if len(ids) == 0 {
return nil, fmt.Errorf("found no issues in bulk edit issue list")
}
// Make a copy of the issue to modify.
x := *old
old = &x
// Try a write to issue -1, checking for formatting only.
old.Number = new(int)
*old.Number = -1
if _, err := writeIssue(old, updated, true); err != nil {
return nil, err
}
// Apply to all issues in list.
suffix := ""
if len(ids) != 1 {
suffix = "s"
}
status(fmt.Sprintf("updating %d issue%s", len(ids), suffix))
failed := false
for index, number := range ids {
if index%10 == 0 && index > 0 {
status(fmt.Sprintf("updated %d/%d issues", index, len(ids)))
}
// Check rate limits here (in contrast to everywhere else in this program)
// to avoid needless failure halfway through the loop.
// for client.Rate.Limit > 0 && client.Rate.Remaining == 0 {
// delta := (client.Rate.Reset.Sub(time.Now())/time.Minute + 2) * time.Minute
{
delta := time.Duration(0)
if delta < 0 {
delta = 2 * time.Minute
}
status(fmt.Sprintf("updated %d/%d issues; pausing %d minutes to respect GitHub rate limit", index, len(ids), int(delta/time.Minute)))
time.Sleep(delta)
if _, _, err := client.RateLimit(); err != nil {
status(fmt.Sprintf("reading rate limit: %v", err))
}
}
*old.Number = number
if _, err := writeIssue(old, updated, true); err != nil {
status(fmt.Sprintf("writing #%d: %s", number, strings.Replace(err.Error(), "\n", "\n\t", -1)))
failed = true
}
}
if failed {
return ids, fmt.Errorf("failed to update all issues")
}
return ids, nil
}