pkg/ioutils: add WriteCloserWrapper

Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
This commit is contained in:
unclejack 2014-08-12 19:20:59 +03:00
parent 27a8494fa3
commit 028b28e406

View file

@ -21,3 +21,19 @@ func NopWriteCloser(w io.Writer) io.WriteCloser {
type NopFlusher struct{} type NopFlusher struct{}
func (f *NopFlusher) Flush() {} func (f *NopFlusher) Flush() {}
type writeCloserWrapper struct {
io.Writer
closer func() error
}
func (r *writeCloserWrapper) Close() error {
return r.closer()
}
func NewWriteCloserWrapper(r io.Writer, closer func() error) io.WriteCloser {
return &writeCloserWrapper{
Writer: r,
closer: closer,
}
}