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

ReadAll

Overview

ReadAll reads r until EOF or ctx is cancelled.

Part of the stream package — Node.js analog: Node stream.

Signature

go
func ReadAll(ctx context.Context, r io.Reader) ([]byte, error)

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"

data, err := stream.ReadAll(ctx, r)

Example

go
import "github.com/sahilkhaire/gox/stream"

data, err := stream.ReadAll(ctx, r)

Tips

Import github.com/sahilkhaire/gox/stream and call ReadAll 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