Skip to content
Node: Node streamgithub.com/sahilkhaire/gox/stream

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.Reader

Compare: Node.js · Standard Go · gox

js
// Typical Node stream pattern in Node.js
go
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)

Back to stream package overview

MIT Licensed · Built for Node.js developers moving to Go