From 8da331e3ea57c9aef07f5438c130f6b2c8b5acd9 Mon Sep 17 00:00:00 2001 From: James Conroy Date: Sat, 31 Jul 2021 22:08:32 -0500 Subject: [PATCH] Don't sleep before the first API call Since arrays are 0 indexed the program immediately sleeps for a minute. This commit makes it so the program only sleeps after 5 api calls have been made. --- main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 298d01d..622b0c3 100644 --- a/main.go +++ b/main.go @@ -36,9 +36,10 @@ func main() { start := time.Now() for i, c := range commodities { - if i%5 == 0 { + if i+1%5 == 0 { elapsed := time.Now().Sub(start) if elapsed < time.Minute { + log.Println("Sleeping because of API limit") time.Sleep(time.Minute - elapsed) } start = time.Now()