This question already has an answer here:
- Golang io/ioutil NopCloser 2 answers
I have an io.Reader
that doesn't require closing:
stringReader := strings.NewReader("shiny!")
And I want to pass it to a method that receives an io.ReadCloser
func readAndClose(source io.ReadCloser) {
...
}
How do I turn the io.Reader
into a io.ReadCloser
without specially creating a struct that implements the Close
method?
</div>