rakyll / statik

Embed files into a Go executable
Apache License 2.0
3.76k stars 224 forks source link

Provide a NewReader on httpFile #43

Closed bhiggins closed 6 years ago

bhiggins commented 6 years ago

I'm interested in using statik for a non-HTTP-serving use case, and one thing that'd make it a bit easier is if I could get a fresh bytes.Reader on the file:

// NewReader returns a new bytes.Reader reading from f.
func (f *httpFile) NewReader() *bytes.Reader {
    return bytes.NewReader(f.data)
}

The reason is because I need to use the file with something that wants an io.ReaderAt. I opted to use io.ReadFull, but that takes a copy of the underlying bytes which I'd like to avoid.

bhiggins commented 6 years ago

(nevermind, I just realized that Open returns an http.File, so this would muddy things...)