code: func retry(attempts int, sleep time.Duration, fn func() error) (err error) { // nolint: unparam
  	for i := 0; ; i++ {
  		err = fn()
  		if err == nil {
  			return
  		}
  		if i >= (attempts - 1) {
  			break
  		}
  		time.Sleep(sleep)
  		log.Println("retrying after error:", err)
  	}
  	return fmt.Errorf("after %d attempts, last error: %s", attempts, err)
  }
docs: // retry periodically retries function fn a specified number of attempts.