const gzipID1 … const gzipID2 … const gzipDeflate … const flagText … const flagHdrCrc … const flagExtra … const flagName … const flagComment … var ErrChecksum … var ErrHeader … var le … // noEOF converts io.EOF to io.ErrUnexpectedEOF. func noEOF(err error) error { … } type Header … type Reader … // NewReader creates a new [Reader] reading the given reader. // If r does not also implement [io.ByteReader], // the decompressor may read more data than necessary from r. // // It is the caller's responsibility to call Close on the [Reader] when done. // // The [Reader.Header] fields will be valid in the [Reader] returned. func NewReader(r io.Reader) (*Reader, error) { … } // Reset discards the [Reader] z's state and makes it equivalent to the // result of its original state from [NewReader], but reading from r instead. // This permits reusing a [Reader] rather than allocating a new one. func (z *Reader) Reset(r io.Reader) error { … } // Multistream controls whether the reader supports multistream files. // // If enabled (the default), the [Reader] expects the input to be a sequence // of individually gzipped data streams, each with its own header and // trailer, ending at EOF. The effect is that the concatenation of a sequence // of gzipped files is treated as equivalent to the gzip of the concatenation // of the sequence. This is standard behavior for gzip readers. // // Calling Multistream(false) disables this behavior; disabling the behavior // can be useful when reading file formats that distinguish individual gzip // data streams or mix gzip data streams with other data streams. // In this mode, when the [Reader] reaches the end of the data stream, // [Reader.Read] returns [io.EOF]. The underlying reader must implement [io.ByteReader] // in order to be left positioned just after the gzip stream. // To start the next stream, call z.Reset(r) followed by z.Multistream(false). // If there is no next stream, z.Reset(r) will return [io.EOF]. func (z *Reader) Multistream(ok bool) { … } // readString reads a NUL-terminated string from z.r. // It treats the bytes read as being encoded as ISO 8859-1 (Latin-1) and // will output a string encoded using UTF-8. // This method always updates z.digest with the data read. func (z *Reader) readString() (string, error) { … } // readHeader reads the GZIP header according to section 2.3.1. // This method does not set z.err. func (z *Reader) readHeader() (hdr Header, err error) { … } // Read implements [io.Reader], reading uncompressed bytes from its underlying [Reader]. func (z *Reader) Read(p []byte) (n int, err error) { … } // Close closes the [Reader]. It does not close the underlying [io.Reader]. // In order for the GZIP checksum to be verified, the reader must be // fully consumed until the [io.EOF]. func (z *Reader) Close() error { … }