func (l *rlReadWriter) Write(b []byte) (n int, err error) {
	packetSize := atomic.LoadUint64(&l.rl.atomicPacketSize)
	if packetSize == 0 {
		return l.writePacket(b)
	}
	for len(b) > 0 {
		var data []byte
		if uint64(len(b)) > packetSize {
			data = b[:packetSize]
			b = b[packetSize:]
		} else {
			data = b
			b = b[:0]
		}
		var written int
		for len(data) > 0 {
			written, err = l.writePacket(data)
			data = data[written:]
			n += written
			if err != nil {
				return
			}
		}
	}
	return
}
// Write writes to the underlying readWriter with the maximum possible speed
// allowed by the rateLimit.
Write writes to the underlying readWriter with the maximum possible speed
allowed by the rateLimit.
// Write writes to the underlying readWriter with the maximum possible speed // allowed by the rateLimit .
func (l *rlReadWriter) Write(b []byte) (n int, err error) {
	packetSize := atomic.LoadUint64(&l.rl.atomicPacketSize)
	if packetSize == 0 {
		return l.writePacket(b)
	}
	for len(b) > 0 {
		var data []byte
		if uint64(len(b)) > packetSize {
			data = b[:packetSize]
			b = b[packetSize:]
		} else {
			data = b
			b = b[:0]
		}
		var written int
		for len(data) > 0 {
			written, err = l.writePacket(data)
			data = data[written:]
			n += written
			if err != nil {
				return
			}
		}
	}
	return
}
func ( l * rlReadWriter ) Write ( b [ ] byte ) ( n int , err error ) { packetSize := atomic . LoadUint64 ( & l . rl . atomicPacketSize ) if packetSize == 0 { return l . writePacket ( b ) } for len ( b ) > 0 { var data [ ] byte if uint64 ( len ( b ) ) > packetSize { data = b [ : packetSize ] b = b [ packetSize : ] } else { data = b b = b [ : 0 ] } var written int for len ( data ) > 0 { written , err = l . writePacket ( data ) data = data [ written : ] n += written if err != nil { return } } } return }
Write writes to the underlying readWriter with the maximum possible speed
allowed by the rateLimit.
Write writes to the underlying readWriter with the maximum possible speed allowed by the rateLimit .