()
| 22 | ) |
| 23 | |
| 24 | func main() { |
| 25 | var username string |
| 26 | fmt.Print("Enter GitHub username: ") |
| 27 | fmt.Scanf("%s", &username) |
| 28 | |
| 29 | rateLimiter := github_ratelimit.New(nil, |
| 30 | github_primary_ratelimit.WithLimitDetectedCallback(func(ctx *github_primary_ratelimit.CallbackContext) { |
| 31 | fmt.Printf("Primary rate limit detected: category %v, reset time: %v\n", ctx.Category, ctx.ResetTime) |
| 32 | }), |
| 33 | github_secondary_ratelimit.WithLimitDetectedCallback(func(ctx *github_secondary_ratelimit.CallbackContext) { |
| 34 | fmt.Printf("Secondary rate limit detected: reset time: %v, total sleep time: %v\n", ctx.ResetTime, ctx.TotalSleepTime) |
| 35 | }), |
| 36 | ) |
| 37 | |
| 38 | paginator := githubpagination.NewClient(rateLimiter, |
| 39 | githubpagination.WithPerPage(100), // default to 100 results per page |
| 40 | ) |
| 41 | client, err := github.NewClient(github.WithHTTPClient(paginator)) |
| 42 | if err != nil { |
| 43 | log.Fatalf("Error creating GitHub client: %v", err) |
| 44 | } |
| 45 | |
| 46 | // Example usage of the client |
| 47 | repos, _, err := client.Repositories.ListByUser(context.Background(), username, nil) |
| 48 | if err != nil { |
| 49 | log.Fatalf("Error: %v", err) |
| 50 | } |
| 51 | |
| 52 | for i, repo := range repos { |
| 53 | fmt.Printf("%v. %v\n", i+1, repo.GetName()) |
| 54 | } |
| 55 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…