MCPcopy Create free account
hub / github.com/google/go-github / main

Function main

example/ratelimit/main.go:24–55  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

22)
23
24func 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}

Callers

nothing calls this directly

Calls 4

NewClientFunction · 0.92
WithHTTPClientFunction · 0.92
ListByUserMethod · 0.80
GetNameMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…