Back to Lo

Core Attemptwhilewithdelay

docs/data/core-attemptwhilewithdelay.md

1.53.0253 B
Original Source

Like AttemptWhile, but pauses between attempts and returns elapsed time.

go
count, dur, err := lo.AttemptWhileWithDelay(
    5,
    time.Millisecond,
    func(i int, d time.Duration) (error, bool) {
        return errors.New("x"), i < 1
    },
)