From ed9118b34620f1ecd5f28506328d4ffe1b04793d Mon Sep 17 00:00:00 2001 From: Wim Date: Sun, 3 Dec 2017 01:24:05 +0100 Subject: Add sshchat dependencies in vendor --- vendor/github.com/shazow/rateio/writer.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 vendor/github.com/shazow/rateio/writer.go (limited to 'vendor/github.com/shazow/rateio/writer.go') diff --git a/vendor/github.com/shazow/rateio/writer.go b/vendor/github.com/shazow/rateio/writer.go new file mode 100644 index 00000000..d4feea49 --- /dev/null +++ b/vendor/github.com/shazow/rateio/writer.go @@ -0,0 +1,25 @@ +package rateio + +import "io" + +type writer struct { + io.Writer + Limiter +} + +// Write writes the contents of p into the buffer. +// Returns ErrRateExceeded error if our specified read is exceeded. +func (w *writer) Write(p []byte) (n int, err error) { + n, err = w.Writer.Write(p) + if err != nil { + return + } + + err = w.Limiter.Count(n) + return +} + +// NewWriter proxies an io.Writer but keeps track of bytes read based on our Limiter. +func NewWriter(w io.Writer, limiter Limiter) io.Writer { + return &writer{w, limiter} +} -- cgit v1.2.3