mirror of
https://github.com/octoleo/restic.git
synced 2024-12-02 18:08:28 +00:00
b9f0f031b6
Closes #2129
21 lines
403 B
Go
21 lines
403 B
Go
package utilities
|
|
|
|
import (
|
|
"bytes"
|
|
"io"
|
|
"io/ioutil"
|
|
)
|
|
|
|
// IOReaderFactory takes in an io.Reader and returns a function that will allow you to create a new reader that begins
|
|
// at the start of the stream
|
|
func IOReaderFactory(r io.Reader) (func() io.Reader, error) {
|
|
b, err := ioutil.ReadAll(r)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return func() io.Reader {
|
|
return bytes.NewReader(b)
|
|
}, nil
|
|
}
|