From f0202b21b3b215307234ee7d4f3a4f9321ac8f65 Mon Sep 17 00:00:00 2001 From: PolovinaD Date: Thu, 31 Mar 2022 00:33:00 +0200 Subject: [PATCH] Fix nil rate limit when adjust-delay is false --- main.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 3a025db..8affd20 100644 --- a/main.go +++ b/main.go @@ -108,6 +108,7 @@ errHandle: err := githubV4Client.Query(context.Background(), result, *variables) duration := time.Since(start).Milliseconds() - int64(time.Millisecond) delayMutex.Lock() + rateLimit = &result.RateLimit if err != nil { handleGraphQLAPIError(err) delayMutex.Unlock() @@ -115,9 +116,9 @@ errHandle: } if adjustDelay { - adjustDelayTime(result.RateLimit) + adjustDelayTime(*rateLimit) } - sleep := int64(requestDelay*result.RateLimit.Cost)*int64(time.Millisecond) - duration + sleep := int64(requestDelay*rateLimit.Cost)*int64(time.Millisecond) - duration delayMutex.Unlock() time.Sleep(time.Duration(sleep)) }