https://github.com/mitchellh/go-linereader
Golang package that reads lines from an io.Reader and puts them onto a channel.
https://github.com/mitchellh/go-linereader
Last synced: about 1 year ago
JSON representation
Golang package that reads lines from an io.Reader and puts them onto a channel.
- Host: GitHub
- URL: https://github.com/mitchellh/go-linereader
- Owner: mitchellh
- License: mit
- Created: 2014-10-05T17:11:03.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2019-02-13T21:33:13.000Z (over 7 years ago)
- Last Synced: 2025-03-30T19:11:40.885Z (about 1 year ago)
- Language: Go
- Size: 3.91 KB
- Stars: 67
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# go-linereader
`go-linereader` (Golang package: `linereader`) is a package for Go that
breaks up the input from an io.Reader into multiple lines. It is
a lot like `bufio.Scanner`, except you can specify timeouts that will push
"lines" through after a certain amount of time. This lets you read lines,
but return any data if a line isn't updated for some time.
## Installation and Usage
Install using `go get github.com/mitchellh/go-linereader`.
Full documentation is available at
http://godoc.org/github.com/mitchellh/go-linereader
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 line reader
lr := linereader.New(r)
// Get all the lines
for line := <-lr.Ch {
// Do something with the line. This line will have the line separator
// removed.
}
```