func (link *Link) SetThroughput(throughput Throughput) {
	link.speed = 1e9 / int64(throughput)
}
SetThroughput sets the current link throughput
package linkio
import (
	"io"
	"time"
)
type Throughput int64
const (
	BitPerSecond      Throughput = 1
	BytePerSecond                = 8 * BitPerSecond
	KilobitPerSecond             = 1024 * BitPerSecond
	KilobytePerSecond            = 1024 * BytePerSecond
	MegabitPerSecond             = 1024 * KilobitPerSecond
	MegabytePerSecond            = 1024 * KilobytePerSecond
	GigabitPerSecond             = 1024 * MegabitPerSecond
	GigabytePerSecond            = 1024 * MegabytePerSecond
)
type LinkReader struct {
	r    io.Reader
	link *Link
}
type LinkWriter struct {
	w    io.Writer
	link *Link
}
type Link struct {
	in    chan linkRequest
	out   chan linkRequest
	speed int64  
}
type linkRequest struct {
	bytes int
	done  chan bool
}
func (link *Link) NewLinkReader(r io.Reader) (s *LinkReader) {
	s = &LinkReader{r: r, link: link}
	return
}
func (link *Link) NewLinkWriter(w io.Writer) (s *LinkWriter) {
	s = &LinkWriter{w: w, link: link}
	return
}
func NewLink(throughput Throughput) (l *Link) {
	l = &Link{in: make(chan linkRequest, 100), out: make(chan linkRequest, 100)}
	l.SetThroughput(throughput)
	go func() {
		for lr := range l.in {
			delay := time.Duration(int64(lr.bytes*8) * l.speed)
			time.Sleep(delay)
			lr.done <- true
		}
	}()
	go func() {
		for lr := range l.out {
			delay := time.Duration(int64(lr.bytes*8) * l.speed)
			time.Sleep(delay)
			lr.done <- true
		}
	}()
	return
}