github.com/lmars/docker@v1.6.0-rc2/pkg/ioutils/writers.go (about) 1 package ioutils 2 3 import "io" 4 5 type NopWriter struct{} 6 7 func (*NopWriter) Write(buf []byte) (int, error) { 8 return len(buf), nil 9 } 10 11 type nopWriteCloser struct { 12 io.Writer 13 } 14 15 func (w *nopWriteCloser) Close() error { return nil } 16 17 func NopWriteCloser(w io.Writer) io.WriteCloser { 18 return &nopWriteCloser{w} 19 } 20 21 type NopFlusher struct{} 22 23 func (f *NopFlusher) Flush() {} 24 25 type writeCloserWrapper struct { 26 io.Writer 27 closer func() error 28 } 29 30 func (r *writeCloserWrapper) Close() error { 31 return r.closer() 32 } 33 34 func NewWriteCloserWrapper(r io.Writer, closer func() error) io.WriteCloser { 35 return &writeCloserWrapper{ 36 Writer: r, 37 closer: closer, 38 } 39 }