Write writes a compressed form of p to the underlying io.Writer. The compressed bytes are not necessarily flushed until the Writer is closed or explicitly flushed.
(p []byte)
| 144 | // compressed bytes are not necessarily flushed until the Writer is closed or |
| 145 | // explicitly flushed. |
| 146 | func (z *Writer) Write(p []byte) (n int, err error) { |
| 147 | if !z.wroteHeader { |
| 148 | z.err = z.writeHeader() |
| 149 | } |
| 150 | if z.err != nil { |
| 151 | return 0, z.err |
| 152 | } |
| 153 | if len(p) == 0 { |
| 154 | return 0, nil |
| 155 | } |
| 156 | n, err = z.compressor.Write(p) |
| 157 | if err != nil { |
| 158 | z.err = err |
| 159 | return |
| 160 | } |
| 161 | z.digest.Write(p) |
| 162 | return |
| 163 | } |
| 164 | |
| 165 | // Flush flushes the Writer to its underlying io.Writer. |
| 166 | func (z *Writer) Flush() error { |