code: func (b *ExponentialBackoff) backoff(failures uint64) time.Duration {
  	if failures <= 0 {
  		// proceed normally when there are no failures.
  		return 0
  	}
  
  	factor := b.config.Factor
  	if factor <= 0 {
  		factor = DefaultExponentialBackoffConfig.Factor
  	}
  
  	backoff := b.config.Base + factor*time.Duration(1<<(failures-1))
  
  	max := b.config.Max
  	if max <= 0 {
  		max = DefaultExponentialBackoffConfig.Max
  	}
  
  	if backoff > max || backoff < 0 {
  		backoff = max
  	}
  
  	// Choose a uniformly distributed value from [0, backoff).
  	return time.Duration(rand.Int63n(int64(backoff)))
  }
docs: // backoff calculates the amount of time to wait based on the number of
  // consecutive failures.