AddSync converts an io.Writer to a WriteSyncer. It attempts to be intelligent: if the concrete type of the io.Writer implements WriteSyncer, we'll use the existing Sync method. If it doesn't, we'll add a no-op Sync.
(w io.Writer)
| 38 | // intelligent: if the concrete type of the io.Writer implements WriteSyncer, |
| 39 | // we'll use the existing Sync method. If it doesn't, we'll add a no-op Sync. |
| 40 | func AddSync(w io.Writer) WriteSyncer { |
| 41 | switch w := w.(type) { |
| 42 | case WriteSyncer: |
| 43 | return w |
| 44 | default: |
| 45 | return writerWrapper{w} |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | type lockedWriteSyncer struct { |
| 50 | sync.Mutex |
no outgoing calls