elgohr / go-stream

A collection of Go Readers and Writers for working with big amounts of data.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

go-stream

Tests codecov CodeQL Go Report Card PkgGoDev License

A collection of io.Reader and io.Writer for working with big amounts of data.
The collection aims for read-once solutions, without the need for buffering.

Installation

go get github.com/elgohr/go-stream

Example on steroids

w := stream.NewSizeWriter()
content := "content"
splitter := stream.NewSuffixSplitter(strings.NewReader(content), 3)
_, err := io.Copy(os.Stderr, io.TeeReader(splitter, w))
if err != nil {
   log.Fatalln(err)
}
originalBufferSize := w.Size()
_, err = io.Copy(os.Stdout, splitter.Suffix())
if err != nil {
   log.Fatalln(err)
}

Outputs:

  • "ent" (suffix) to os.Stdout
  • "cont" to os.Stderr
  • 7 as originalBufferSize

Usage

Please see examples.

About

A collection of Go Readers and Writers for working with big amounts of data.

License:Apache License 2.0


Languages

Language:Go 100.0%