diff options
author | Keuin <[email protected]> | 2022-09-08 13:28:16 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2022-09-08 13:28:16 +0800 |
commit | 570d199e133aac019b51dea2b336e756693e0ffd (patch) | |
tree | 82972bb984b29e539582f31333d8eda4f425d258 | |
parent | 177ecb3de2f9ca8e23c3eeb19b6875a0c6593355 (diff) |
Bugfix: AutoRetry retry counter and error returning is not properly implemented
-rw-r--r-- | common/retry.go | 5 |
1 files 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", |