strings.NewReader
The Go function that turns a string into an io.Reader, so text can be fed to code that expects a stream.
In more detail
It is the quickest way to give a function test input without creating a file. The strings package also holds everyday text helpers such as Split, TrimSpace and Contains.
Example
strings.NewReader("0123456789")Related terms
- io.Reader — The Go interface for anything you can read bytes from, such as a file, a network connection or an HTTP response body.
- string — A sequence of characters, that is, a piece of text.
- test fixture — Fixed, known data or setup that tests use so their results are predictable, such as a sample file, a seeded database or a started application.
Taught in
- Streams and the io Package — Concurrent Systems Programming with Go