Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. // 1. Prints: A
  2. retry(3, time.Second, func() error {
  3. fmt.Print("A")
  4. return nil
  5. })
  6.  
  7. // 2. Prints: BB
  8. var i int
  9. retry(3, time.Second, func() error {
  10. i++
  11. fmt.Print("B")
  12. if i == 2 {
  13. return stop{errors.New("stop it")}
  14. }
  15. return errors.New("keep going")
  16. })
  17.  
  18. // 3. Prints: CCC
  19. retry(3, time.Second, func() error {
  20. fmt.Print("C")
  21. return errors.New("not today")
  22. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement