recurse.go 232 B

123456789101112
  1. package testhelpers
  2. // Recurse calls itself 'depth' times then executes 'f'. Useful for testing things where stack size matters.
  3. func Recurse(depth int, f func()) {
  4. if depth > 0 {
  5. depth--
  6. Recurse(depth, f)
  7. return
  8. }
  9. f()
  10. }