TeeReader
Overview
TeeReader returns a Reader that writes to w what it reads from r. Node: passThrough with tap
Part of the stream package — Node.js analog: Node stream.
Signature
go
func TeeReader(r io.Reader, w io.Writer) io.ReaderCompare: Node.js · Standard Go · gox
js
// Typical Node stream pattern in Node.jsgo
io.Copy(dst, src)
// or io.ReadAll(r)go
import "github.com/sahilkhaire/gox/stream"
reader := stream.TeeReader(r, auditWriter)Example
go
import "github.com/sahilkhaire/gox/stream"
reader := stream.TeeReader(r, auditWriter)Tips
Import github.com/sahilkhaire/gox/stream and call TeeReader directly. See the comparison below for the standard library equivalent.
Standard library alternative
Use the standard library directly:
go
io.Copy(dst, src)
// or io.ReadAll(r)