| 1 | package rsync |
| 2 | |
| 3 | import "io" |
| 4 | |
| 5 | // BothCloser is a wrapper around a ReadCloser and WriteCloser that provides its |
| 6 | // own Close() function which calls Close() on both, the WriteCloser and |
| 7 | // ReadCloser, in order, and returns the first non-nil error. |
| 8 | type BothCloser struct { |
| 9 | io.ReadCloser |
| 10 | io.WriteCloser |
| 11 | } |
| 12 | |
| 13 | // Close implements io.Closer. |
| 14 | func (b *BothCloser) Close() error { |
| 15 | wcErr := b.WriteCloser.Close() |
| 16 | rcErr := b.ReadCloser.Close() |
| 17 | if wcErr != nil { |
| 18 | return wcErr |
| 19 | } |
| 20 | return rcErr |
| 21 | } |