func updateIssue(client *octokit.Client, number int, level string) error { labels := []string{"bug", "duplicate"} if len(level) > 0 { labels = append(labels, level) } var params octokit.IssueParams params = octokit.IssueParams{ Labels: labels} issueInfo := octokit.M{"owner": owner, "repo": repo, "number": number} pastIssue, pastIssueResult := client.Issues().One(nil, issueInfo) if !pastIssueResult.HasError() { now := time.Now() timestamp := now.Format(time.RFC850) bodyBuffer := new(bytes.Buffer) bodyBuffer.WriteString(pastIssue.Body) bodyBuffer.WriteString("\n") bodyBuffer.WriteString(timestamp) body := bodyBuffer.String() params = octokit.IssueParams{ Body: body, Labels: labels} } _, result := client.Issues().Update(nil, issueInfo, params) if result.HasError() { return result.Err } return nil }
func createIssue(client *octokit.Client, title string, body string, level string) error { labels := []string{"bug"} if len(level) > 0 { labels = append(labels, level) } params := octokit.IssueParams{ Title: title, Body: body, Labels: labels} time.Now() _, result := client.Issues().Create(nil, octokit.M{"owner": owner, "repo": repo}, params) if result.HasError() { return result.Err } return nil }