Skip to content

Commit b63bb4a

Browse files
committed
improve code
1 parent fad9df1 commit b63bb4a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

modules/migrations/github.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,12 @@ func (g *GithubDownloaderV3) SetContext(ctx context.Context) {
116116

117117
func (g *GithubDownloaderV3) sleep() {
118118
for g.rate != nil && g.rate.Remaining <= 0 {
119+
timer := time.NewTimer(time.Now().Sub(g.rate.Reset.Time))
119120
select {
120121
case <-g.ctx.Done():
122+
timer.Stop()
121123
return
122-
case <-time.After(time.Now().Sub(g.rate.Reset.Time)):
124+
case <-timer.C:
123125
}
124126

125127
rates, _, err := g.client.RateLimits(g.ctx)

0 commit comments

Comments
 (0)