Documentation ¶
Index ¶
- Variables
- func AutoDecompress(stream io.Reader) (io.ReadCloser, bool, error)
- func Bzip2Decompressor(r io.Reader) (io.ReadCloser, error)
- func CompressStream(dest io.Writer, algo Algorithm, level *int) (io.WriteCloser, error)
- func DetectCompressionFormat(input io.Reader) (Algorithm, DecompressorFunc, io.Reader, error)
- func GzipDecompressor(r io.Reader) (io.ReadCloser, error)
- func XzDecompressor(r io.Reader) (io.ReadCloser, error)
- func ZstdDecompressor(r io.Reader) (io.ReadCloser, error)
- type Algorithm
- type DecompressorFunc
Constants ¶
This section is empty.
Variables ¶
var ( // Gzip compression. Gzip = internal.NewAlgorithm("gzip", []byte{0x1F, 0x8B, 0x08}, GzipDecompressor, gzipCompressor) // Bzip2 compression. Bzip2 = internal.NewAlgorithm("bzip2", []byte{0x42, 0x5A, 0x68}, Bzip2Decompressor, bzip2Compressor) // Xz compression. Xz = internal.NewAlgorithm("Xz", []byte{0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00}, XzDecompressor, xzCompressor) // Zstd compression. Zstd = internal.NewAlgorithm("zstd", []byte{0x28, 0xb5, 0x2f, 0xfd}, ZstdDecompressor, zstdCompressor) )
Functions ¶
func AutoDecompress ¶
AutoDecompress takes a stream and returns an uncompressed version of the same stream. The caller must call Close() on the returned stream (even if the input does not need, or does not even support, closing!).
func Bzip2Decompressor ¶
func Bzip2Decompressor(r io.Reader) (io.ReadCloser, error)
Bzip2Decompressor is a DecompressorFunc for the bzip2 compression algorithm.
func CompressStream ¶
CompressStream returns the compressor by its name
func DetectCompressionFormat ¶
DetectCompressionFormat returns a DecompressorFunc if the input is recognized as a compressed format, nil otherwise. Because it consumes the start of input, other consumers must use the returned io.Reader instead to also read from the beginning.
func GzipDecompressor ¶
func GzipDecompressor(r io.Reader) (io.ReadCloser, error)
GzipDecompressor is a DecompressorFunc for the gzip compression algorithm.
func XzDecompressor ¶
func XzDecompressor(r io.Reader) (io.ReadCloser, error)
XzDecompressor is a DecompressorFunc for the xz compression algorithm.
func ZstdDecompressor ¶
func ZstdDecompressor(r io.Reader) (io.ReadCloser, error)
ZstdDecompressor is a DecompressorFunc for the zstd compression algorithm.
Types ¶
type Algorithm ¶
Algorithm is a compression algorithm that can be used for CompressStream.
func AlgorithmByName ¶
AlgorithmByName returns the compressor by its name
type DecompressorFunc ¶
type DecompressorFunc = internal.DecompressorFunc
DecompressorFunc returns the decompressed stream, given a compressed stream. The caller must call Close() on the decompressed stream (even if the compressed input stream does not need closing!).
func DetectCompression ¶
DetectCompression returns a DecompressorFunc if the input is recognized as a compressed format, nil otherwise. Because it consumes the start of input, other consumers must use the returned io.Reader instead to also read from the beginning.