File: README.md

package info (click to toggle)
golang-github-mitchellh-prefixedio 0.0~git20190213.5733675-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 76 kB
  • sloc: makefile: 2
file content (30 lines) | stat: -rw-r--r-- 784 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# prefixedio

`prefixedio` (Golang package: `prefixedio`) is a package for Go
that takes an `io.Reader` and de-multiplexes line-oriented data based
on a line prefix to a set of readers.

## Installation and Usage

Install using `go get github.com/mitchellh/prefixedio`.

Full documentation is available at
http://godoc.org/github.com/mitchellh/prefixedio

Below is an example of its usage ignoring errors:

```go
// Assume r is some set io.Reader. Perhaps a file, network, anything.
var r io.Reader

// Initialize the prefixed reader
pr, _ := prefixedio.NewReader(r)

// Grab readers for a couple prefixes
errR, _ := pr.Prefix("err: ")
outR, _ := pr.Prefix("out: ")

// Copy the data to different places based on the prefix
go io.Copy(os.Stderr, errR)
go io.Copy(os.Stdout, outR)
```