Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 1. Prints: A
- retry(3, time.Second, func() error {
- fmt.Print("A")
- return nil
- })
- // 2. Prints: BB
- var i int
- retry(3, time.Second, func() error {
- i++
- fmt.Print("B")
- if i == 2 {
- return stop{errors.New("stop it")}
- }
- return errors.New("keep going")
- })
- // 3. Prints: CCC
- retry(3, time.Second, func() error {
- fmt.Print("C")
- return errors.New("not today")
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement