https://github.com/connerdouglass/go-linereader
Stream lines from an io.Reader in Go
https://github.com/connerdouglass/go-linereader
delimiter golang line reader streaming
Last synced: 3 months ago
JSON representation
Stream lines from an io.Reader in Go
- Host: GitHub
- URL: https://github.com/connerdouglass/go-linereader
- Owner: connerdouglass
- License: mit
- Created: 2021-10-25T18:51:16.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-10-25T18:55:06.000Z (over 3 years ago)
- Last Synced: 2025-03-18T01:51:29.398Z (3 months ago)
- Topics: delimiter, golang, line, reader, streaming
- Language: Go
- Homepage:
- Size: 3.91 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-linereader
A small library for streaming lines from an `io.Reader`.
## Example
```go
// Create a default LineReader, delimited by newlines
lr := linereader.New( source /* io.Reader */ )
for {// Read a single line from the reader
line, err := lr.Line()
if err != nil {
panic(err)
}// A nil line means we've reached the end of the stream
if line == nil {
break
}// Print the found line
fmt.Println("LINE: ", string(line))}
```## Using custom delimiters
```go
lr := linereader.WithDelimiter(
source, /* io.Reader */
[]byte("zz"),
)
```The above example uses `zz` as a delimiter. Splitting `fizzbuzz123` by that delimiter would result in `[fi, bu, 123]`.