package gzip

Import Path
	compress/gzip (on golang.org and go.dev)

Dependency Relation
	imports 8 packages, and imported by one package

Involved Source Files
	d-> gunzip.go
	    gzip.go

Exported Type Names

type Header (struct) The gzip file stores a header giving metadata about the compressed file. That header is exposed as the fields of the Writer and Reader structs. Strings must be UTF-8 encoded and may only contain Unicode code points U+0001 through U+00FF, due to limitations of the GZIP file format. Comment string Extra []byte ModTime time.Time Name string OS byte
type Reader (struct) A Reader is an io.Reader that can be read to retrieve uncompressed data from a gzip-format compressed file. In general, a gzip file can be a concatenation of gzip files, each with its own header. Reads from the Reader return the concatenation of the uncompressed data of each. Only the first header is recorded in the Reader fields. Gzip files store a length and checksum of the uncompressed data. The Reader will return an ErrChecksum when Read reaches the end of the uncompressed data if it does not have the expected length or checksum. Clients should treat data returned by Read as tentative until they receive the io.EOF marking the end of the data. Header Header Header.Comment string Header.Extra []byte Header.ModTime time.Time Header.Name string Header.OS byte (*T) Close() error (*T) Multistream(ok bool) (*T) Read(p []byte) (n int, err error) (*T) Reset(r io.Reader) error *T : io.Closer *T : io.ReadCloser *T : io.Reader func NewReader(r io.Reader) (*Reader, error)
type Writer (struct) A Writer is an io.WriteCloser. Writes to a Writer are compressed and written to w. Header Header Header.Comment string Header.Extra []byte Header.ModTime time.Time Header.Name string Header.OS byte (*T) Close() error (*T) Flush() error (*T) Reset(w io.Writer) (*T) Write(p []byte) (int, error) *T : io.Closer *T : io.WriteCloser *T : io.Writer func NewWriter(w io.Writer) *Writer func NewWriterLevel(w io.Writer, level int) (*Writer, error)
Exported Values
const BestCompression = 9 These constants are copied from the flate package, so that code that imports "compress/gzip" does not also have to import "compress/flate".
const BestSpeed = 1 These constants are copied from the flate package, so that code that imports "compress/gzip" does not also have to import "compress/flate".
const DefaultCompression = -1 These constants are copied from the flate package, so that code that imports "compress/gzip" does not also have to import "compress/flate".
var ErrChecksum error ErrChecksum is returned when reading GZIP data that has an invalid checksum.
var ErrHeader error ErrHeader is returned when reading GZIP data that has an invalid header.
const HuffmanOnly = -2 These constants are copied from the flate package, so that code that imports "compress/gzip" does not also have to import "compress/flate".
func NewReader(r io.Reader) (*Reader, error) 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 NewWriter(w io.Writer) *Writer NewWriter returns 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. Callers that wish to set the fields in Writer.Header must do so before the first call to Write, Flush, or Close.
func NewWriterLevel(w io.Writer, level int) (*Writer, error) 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.
const NoCompression = 0 These constants are copied from the flate package, so that code that imports "compress/gzip" does not also have to import "compress/flate".