type writer … const maxCode … const invalidCode … const tableSize … const tableMask … const invalidEntry … type Writer … // writeLSB writes the code c for "Least Significant Bits first" data. func (w *Writer) writeLSB(c uint32) error { … } // writeMSB writes the code c for "Most Significant Bits first" data. func (w *Writer) writeMSB(c uint32) error { … } var errOutOfCodes … // incHi increments e.hi and checks for both overflow and running out of // unused codes. In the latter case, incHi sends a clear code, resets the // writer state and returns errOutOfCodes. func (w *Writer) incHi() error { … } // Write writes a compressed representation of p to w's underlying writer. func (w *Writer) Write(p []byte) (n int, err error) { … } // Close closes the [Writer], flushing any pending output. It does not close // w's underlying writer. func (w *Writer) Close() error { … } // Reset clears the [Writer]'s state and allows it to be reused again // as a new [Writer]. func (w *Writer) Reset(dst io.Writer, order Order, litWidth int) { … } // NewWriter creates a new [io.WriteCloser]. // Writes to the returned [io.WriteCloser] are compressed and written to w. // It is the caller's responsibility to call Close on the WriteCloser when // finished writing. // The number of bits to use for literal codes, litWidth, must be in the // range [2,8] and is typically 8. Input bytes must be less than 1<<litWidth. // // It is guaranteed that the underlying type of the returned [io.WriteCloser] // is a *[Writer]. func NewWriter(w io.Writer, order Order, litWidth int) io.WriteCloser { … } func newWriter(dst io.Writer, order Order, litWidth int) *Writer { … } func (w *Writer) init(dst io.Writer, order Order, litWidth int) { … }