code: func (r *RateLimiter) Limit(dataSize int) time.Duration {
  	r.lock.Lock()
  	defer r.lock.Unlock()
  	//  update time
  	var duration time.Duration = time.Duration(0)
  	if r.bandwidth == 0 {
  		return duration
  	}
  	current := time.Now()
  	elapsedTime := current.Sub(r.lastUpdate)
  	r.lastUpdate = current
  
  	allowance := r.allowance + float64(elapsedTime)*r.bandwidth
  	//  allowance can't exceed bandwidth
  	if allowance > r.maxAllowance {
  		allowance = r.maxAllowance
  	}
  
  	allowance -= float64(dataSize)
  	if allowance < 0 {
  		//  sleep until allowance is back to 0
  		duration = time.Duration(-allowance / r.bandwidth)
  		//  rate limiting was applied, record stats
  		r.count++
  		r.duration += duration
  	}
  
  	r.allowance = allowance
  	return duration
  }
docs: //  Returns how long to wait before sending data with length 'dataSize' bytes