Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/makew0rld/rr
RestartReader - read bytes from an io.Reader without removing them
https://github.com/makew0rld/rr
Last synced: 26 days ago
JSON representation
RestartReader - read bytes from an io.Reader without removing them
- Host: GitHub
- URL: https://github.com/makew0rld/rr
- Owner: makew0rld
- License: mit
- Created: 2022-01-18T14:40:49.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-18T14:49:16.000Z (almost 3 years ago)
- Last Synced: 2024-10-26T22:25:51.016Z (2 months ago)
- Language: Go
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `rr`, aka `RestartReader`
`RestartReader` allows you to read bytes from an io.Reader without removing them.
`RestartReader` wraps `io.ReadCloser` or `io.Reader` and implements it. It holds the data from every `Read` in a buffer, and allows you to call `.Restart()`, causing subsequent `Read` calls to start from the beginning again. This is useful when you need to read the first few bytes of a stream or file, before passing off the full data to another function.
Import it with:
```
go get github.com/makeworld-the-better-one/rr
```## License
MIT