Debian Codegraph @

example/migrations/main.go

raw
1 // Copyright 2018 The go-github AUTHORS. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file.
5
6 // migrations demonstrates the functionality of
7 // the user data migration API for the authenticated GitHub
8 // user and lists all the user migrations.
9 package main
10
11 import (
12 "context"
13 "fmt"
14
15 "github.com/google/go-github/v60/github"
16 )
17
18 func fetchAllUserMigrations() ([]*github.UserMigration, error) {
19 ctx := context.Background()
20 client := github.NewClient(nil).WithAuthToken("<GITHUB_AUTH_TOKEN>")
21
22 migrations, _, err := client.Migrations.ListUserMigrations(ctx, &github.ListOptions{Page: 1})
23 return migrations, err
24 }
25
26 func main() {
27 migrations, err := fetchAllUserMigrations()
28 if err != nil {
29 fmt.Printf("Error %v\n", err)
30 return
31 }
32
33 for i, m := range migrations {
34 fmt.Printf("%v. %v", i+1, m.GetID())
35 }
36 }