~adnano/astronaut

astronaut/io.go -rw-r--r-- 318 bytes
947cfac7Adnan Maolood Update default bindings 17 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package main

import (
	"io"
)

type teeReader struct {
	r io.ReadCloser
	w io.Writer
}

func (t *teeReader) Read(p []byte) (n int, err error) {
	n, err = t.r.Read(p)
	if n > 0 {
		if n, err := t.w.Write(p[:n]); err != nil {
			return n, err
		}
	}
	return
}

func (t *teeReader) Close() error {
	return t.r.Close()
}