-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathissues.go
More file actions
50 lines (43 loc) · 1.26 KB
/
issues.go
File metadata and controls
50 lines (43 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Issues prints a table of GitHub issues matching search terms
package main
import (
"fmt"
"log"
"os"
"time"
"github.com/travertischio/addison-wesley/github"
)
func main() {
now := time.Now()
lastMonth := now.AddDate(0, -1, 0)
lastYear := now.AddDate(-1, 0, 0)
var thisMonth = make([]*github.Issue, 0)
var thisYear = make([]*github.Issue, 0)
var older = make([]*github.Issue, 0)
result, err := github.SearchIssues(os.Args[1:])
if err != nil {
log.Fatal(err)
}
for _, item := range result.Items {
if item.CreatedAt.Before(lastYear) {
older = append(older, item)
} else if item.CreatedAt.Before(lastMonth) {
thisYear = append(thisYear, item)
} else {
thisMonth = append(thisMonth, item)
}
}
fmt.Printf("%d issues:\n", result.TotalCount)
fmt.Println("Less than a month old")
for _, item := range thisMonth {
fmt.Printf("#%-5d %9.9s %.55s\n", item.Number, item.User.Login, item.Title)
}
fmt.Println("\nLess than a year old")
for _, item := range thisYear {
fmt.Printf("#%-5d %9.9s %.55s\n", item.Number, item.User.Login, item.Title)
}
fmt.Println("\nOlder than one year")
for _, item := range older {
fmt.Printf("#%-5d %9.9s %.55s\n", item.Number, item.User.Login, item.Title)
}
}