2014-08-12 16:10:43 +00:00
|
|
|
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() {}
|
2014-08-12 16:20:59 +00:00
|
|
|
|
|
|
|
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,
|
|
|
|
}
|
|
|
|
}
|