| Conditions | 3 |
| Total Lines | 26 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | package main |
||
| 13 | func main() { |
||
| 14 | utils.InfoNotice(` GitHub Token Limit Checker `) |
||
| 15 | utils.InfoNotice(` v1.0.0 `) |
||
| 16 | println("") // This is a placeholder for the main function |
||
| 17 | |||
| 18 | client := &http.Client{} |
||
| 19 | token := os.Getenv(githubapi.TokenEnvName) |
||
| 20 | |||
| 21 | rateLimitResponse, err := githubapi.FetchRateLimit(client, token) |
||
| 22 | if err != nil { |
||
| 23 | utils.ErrorNotice(fmt.Sprintf("Error fetching rate limit: %v\n", err)) |
||
| 24 | os.Exit(3) |
||
| 25 | } |
||
| 26 | |||
| 27 | core := rateLimitResponse.Resources.Core |
||
| 28 | resetTime := core.Reset.Time |
||
| 29 | //fmt.Printf("%+v\n", core) |
||
| 30 | |||
| 31 | if core.Remaining > 0 { |
||
| 32 | utils.InfoNotice(fmt.Sprintf(" You have %d/%d requests left this hour", core.Remaining, core.Limit)) |
||
| 33 | } else { |
||
| 34 | now := time.Now() |
||
| 35 | durationUntilReset := resetTime.Sub(now).Minutes() |
||
| 36 | utils.InfoNotice(fmt.Sprintf(" You have no requests left. The limit will reset in %.0f minute at %s", durationUntilReset, resetTime)) |
||
| 37 | } |
||
| 38 | println("") |
||
| 39 | } |
||
| 40 |