File: ioutil.go

package info (click to toggle)
golang-github-anacrolix-missinggo 2.1.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 836 kB
  • sloc: makefile: 4
file content (30 lines) | stat: -rw-r--r-- 453 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package missinggo

import "io"

type StatWriter struct {
	Written int64
	w       io.Writer
}

func (me *StatWriter) Write(b []byte) (n int, err error) {
	n, err = me.w.Write(b)
	me.Written += int64(n)
	return
}

func NewStatWriter(w io.Writer) *StatWriter {
	return &StatWriter{w: w}
}

var ZeroReader zeroReader

type zeroReader struct{}

func (me zeroReader) Read(b []byte) (n int, err error) {
	for i := range b {
		b[i] = 0
	}
	n = len(b)
	return
}