const NoCompression … const BestSpeed … const BestCompression … const DefaultCompression … const HuffmanOnly … type Writer … // NewWriter creates a new Writer. // Writes to the returned Writer are compressed and written to w. // // It is the caller's responsibility to call Close on the Writer when done. // Writes may be buffered and not flushed until Close. func NewWriter(w io.Writer) *Writer { … } // NewWriterLevel is like NewWriter but specifies the compression level instead // of assuming DefaultCompression. // // The compression level can be DefaultCompression, NoCompression, HuffmanOnly // or any integer value between BestSpeed and BestCompression inclusive. // The error returned will be nil if the level is valid. func NewWriterLevel(w io.Writer, level int) (*Writer, error) { … } // NewWriterLevelDict is like NewWriterLevel but specifies a dictionary to // compress with. // // The dictionary may be nil. If not, its contents should not be modified until // the Writer is closed. func NewWriterLevelDict(w io.Writer, level int, dict []byte) (*Writer, error) { … } // Reset clears the state of the Writer z such that it is equivalent to its // initial state from NewWriterLevel or NewWriterLevelDict, but instead writing // to w. func (z *Writer) Reset(w io.Writer) { … } // writeHeader writes the ZLIB header. func (z *Writer) writeHeader() (err error) { … } // 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. func (z *Writer) Write(p []byte) (n int, err error) { … } // Flush flushes the Writer to its underlying io.Writer. func (z *Writer) Flush() error { … } // Close closes the Writer, flushing any unwritten data to the underlying // io.Writer, but does not close the underlying io.Writer. func (z *Writer) Close() error { … }