From 570d199e133aac019b51dea2b336e756693e0ffd Mon Sep 17 00:00:00 2001 From: Keuin Date: Thu, 8 Sep 2022 13:28:16 +0800 Subject: Bugfix: AutoRetry retry counter and error returning is not properly implemented --- common/retry.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common/retry.go b/common/retry.go index 1b28e1b..1751679 100644 --- a/common/retry.go +++ b/common/retry.go @@ -17,8 +17,9 @@ func AutoRetry[T any]( retryInterval time.Duration, logger *log.Logger) (T, error) { var err error - for i := 0; i < maxRetryTimes; i++ { - ret, err := supplier() + var ret T + for i := 0; i < maxRetryTimes+1; i++ { + ret, err = supplier() if err != nil { if logger != nil { logger.Printf("Try %v/%v (sleep %vs): %v", -- cgit v1.2.3