Documentation
¶
Overview ¶
Package compress provides convenience functions for creating compressors and uncompressors based on filenames.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewReader ¶
func NewReader(r io.Reader) (io.ReadCloser, bool)
NewReader creates an uncompressing reader by reading the first few bytes of the input and finding a magic header for either gzip or bzip2. If the magic header is found , it returns an uncompressing ReadCloser and true. Else, it returns ioutil.NopCloser(r) and false.
CAUTION: this function will misbehave when the input is a binary string that happens to have the same magic gzip or bzip2 header. Thus, you should use this function only when the input is expected to be ASCII.
func NewReaderPath ¶
func NewReaderPath(r io.Reader, path string) io.ReadCloser
NewReaderPath creates a reader that uncompresses data read from the given reader. The compression format is determined by the pathname extensions. The following extensions are recognized:
.gz => gzip format .bz2 => bz2 format
For other extensions, this function returns nil.
If the caller receives a non-nil reader from this function, it must close the reader after use. For some file formats, Close() is the only place that reports file corruption.
func NewWriterPath ¶
func NewWriterPath(w io.Writer, path string) io.WriteCloser
NewWriterPath creates a WriteCloser that compresses data. The compression format is determined by the pathname extensions. The following extension is recognized:
.gz => gzip format
For other extensions, this function returns nil. If this function returns a non-nil writecloser, the caller must call Close() once after writing all the data.
Types ¶
This section is empty.