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.jsgo
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)