Documentation ¶
Index ¶
- func BytesSize(size B) string
- func ConnGear(rw net.Conn, r, w *Gear) net.Conn
- func CustomSize(format string, size B, base B, _map []string) string
- func GearConn(conn net.Conn, duration time.Duration, limit B) net.Conn
- func GearReadWriter(rw io.ReadWriter, duration time.Duration, limit B) io.ReadWriter
- func GearReader(r io.Reader, duration time.Duration, limit B) io.Reader
- func GearWriter(w io.Writer, duration time.Duration, limit B) io.Writer
- func HumanSizeWithPrecision(size B, precision int) string
- func ReadWriterGear(rw io.ReadWriter, r, w *Gear) io.ReadWriter
- type B
- type BPS
- type Gear
- func (g *Gear) Aver() B
- func (g *Gear) BPS() *BPS
- func (g *Gear) Conn(rw net.Conn) net.Conn
- func (g *Gear) LastAver() B
- func (g *Gear) Limit() B
- func (g *Gear) MaxAver() B
- func (g *Gear) ReadWriter(rw io.ReadWriter) io.ReadWriter
- func (g *Gear) Reader(r io.Reader) io.Reader
- func (g *Gear) SetLimit(b B)
- func (g *Gear) Total() B
- func (g *Gear) Writer(w io.Writer) io.Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesSize ¶
BytesSize returns a human-readable size in bytes, kibibytes, mebibytes, gibibytes, or tebibytes (eg. "44kiB", "17MiB").
func CustomSize ¶
CustomSize returns a human-readable approximation of a size using custom format.
func GearReadWriter ¶
func GearReadWriter(rw io.ReadWriter, duration time.Duration, limit B) io.ReadWriter
GearReadWriter is limit the speed of reading and writing from io.ReadWriter
func GearReader ¶
GearReader is limit the speed of reading from io.Reader
func GearWriter ¶
GearWriter is limit the speed of writing to io.Writer
func HumanSizeWithPrecision ¶
HumanSizeWithPrecision allows the size to be in any precision
func ReadWriterGear ¶
func ReadWriterGear(rw io.ReadWriter, r, w *Gear) io.ReadWriter
Types ¶
type B ¶
type B float64
func FromBytesSize ¶
FromBytesSize returns an integer from a human-readable specification of a size using binary standard (eg. "44kiB", "17MiB").
func FromHumanSize ¶
FromHumanSize returns an integer from a human-readable specification of a size using SI standard (eg. "44kB", "17MB").
type Gear ¶
type Gear struct {
// contains filtered or unexported fields
}
func (*Gear) ReadWriter ¶
func (g *Gear) ReadWriter(rw io.ReadWriter) io.ReadWriter