mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
7b6f34057c
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
39 lines
646 B
Go
39 lines
646 B
Go
package ioutils
|
|
|
|
import "io"
|
|
|
|
type NopWriter struct{}
|
|
|
|
func (*NopWriter) Write(buf []byte) (int, error) {
|
|
return len(buf), nil
|
|
}
|
|
|
|
type nopWriteCloser struct {
|
|
io.Writer
|
|
}
|
|
|
|
func (w *nopWriteCloser) Close() error { return nil }
|
|
|
|
func NopWriteCloser(w io.Writer) io.WriteCloser {
|
|
return &nopWriteCloser{w}
|
|
}
|
|
|
|
type NopFlusher struct{}
|
|
|
|
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,
|
|
}
|
|
}
|