Documentation
¶
Overview ¶
Package zreader implements a transparently decompressing io.Reader.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Reader ¶
func Reader(r io.Reader) (rc io.ReadCloser, err error)
Reader returns an io.ReadCloser that transparently reads bytes compressed with one of the following schemes:
- gzip
- zstd
- bzip2
If the data does not seem to be one of these schemes, a new io.ReadCloser equivalent to the provided io.Reader is returned. The provided io.Reader is expected to have any necessary cleanup arranged by the caller; that is, it will not arrange for a Close method to be called if it also implements io.Closer.
Types ¶
type Compression ¶
type Compression int
Compression marks the scheme that the original Reader contains.
const ( KindGzip Compression = iota KindZstd KindBzip2 KindNone )
Compression constants.
func Detect ¶
func Detect(r io.Reader) (io.ReadCloser, Compression, error)
Detect follows the same procedure as Reader, but also reports the detected compression scheme.
func DetectCompression ¶ added in v1.6.0
func DetectCompression(b []byte) Compression
DetectCompression reports the compression type indicated based on the header contained in the passed byte slice.
KindNone is returned if all detectors report false, but it's possible that it's just a scheme unsupported by this package.
func (Compression) String ¶
func (i Compression) String() string