github.com/sandwich-go/boost@v1.3.29/retry/README.md (about) 1 # retry 2 3 执行函数,若失败,则按配置参数重新执行,直至成功或达到某种指定条件 4 5 # 例子 6 7 ```go 8 var retrySum uint 9 err := Do( 10 func(uint) error { return fmt.Errorf("%d", retrySum) }, 11 WithOnRetry(func(n uint, err error) { retrySum += 1 }), 12 WithDelay(time.Nanosecond), 13 WithLastErrorOnly(true), 14 ) 15 16 fmt.Println(err) 17 ``` 18 19 Output: 20 ```text 21 9 22 ```