You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

stats.go 337 B

12345678910111213141516171819202122
  1. package io2
  2. import "io"
  3. type Counter struct {
  4. inner io.Reader
  5. count int64
  6. }
  7. func (c *Counter) Read(buf []byte) (n int, err error) {
  8. n, err = c.inner.Read(buf)
  9. c.count += int64(n)
  10. return
  11. }
  12. func (c *Counter) Count() int64 {
  13. return c.count
  14. }
  15. func NewCounter(inner io.Reader) *Counter {
  16. return &Counter{inner: inner, count: 0}
  17. }