-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.go
47 lines (37 loc) · 933 Bytes
/
app.go
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
package main
import (
"context"
"github.com/go-playground/log/v8"
"github.com/google/go-github/github"
)
// App struct
type App struct {
ctx context.Context
}
// NewApp creates a new App application struct
func NewApp() *App {
return &App{}
}
// startup is called when the app starts. The context is saved
// so we can call the runtime methods
func (a *App) startup(ctx context.Context) {
a.ctx = ctx
cLog := new(CustomHandler)
log.AddHandler(cLog, log.AllLevels...)
}
// GetGithubRepositories per page the given username
func (a *App) GetGithubRepositories(username string, page int) []*github.Repository {
client := github.NewClient(nil)
repos, _, err := client.Repositories.List(context.Background(), username, &github.RepositoryListOptions{
Sort: "updated",
ListOptions: github.ListOptions{
PerPage: 100,
Page: page,
},
})
if err != nil {
log.Fatal(err)
}
log.Info(repos)
return repos
}