-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmain.go
39 lines (31 loc) · 827 Bytes
/
main.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
package main
import (
"context"
"fmt"
"log"
"github.com/shurcooL/githubv4"
"golang.org/x/oauth2"
)
func main() {
config := NewConfig()
src := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: config.GitHub.Token},
)
httpClient := oauth2.NewClient(context.Background(), src)
client := githubv4.NewClient(httpClient)
var q struct {
RepositoryOwner `graphql:"repositoryOwner(login: $login)"`
}
variables := map[string]interface{}{
"login": githubv4.String("skanehira"),
"first": githubv4.Int(20),
"cursor": (*githubv4.String)(nil),
}
if err := client.Query(context.Background(), &q, variables); err != nil {
log.Fatal(err)
}
for _, node := range q.RepositoryOwner.Repositories.Nodes {
fmt.Println(node.NameWithOwner)
}
fmt.Println(q.RepositoryOwner.Repositories.PageInfo.EndCursor)
}