Documentation ¶
Overview ¶
Package gompress provides both a CLI interface, and a golang library for working with various compression algorithms. Currently supported are
brotli bzip2 deflate gzip lz4 lzma2 lzo snappy xz zlib zstd
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Brotli ¶
type Brotli struct {
*CompressionLevel
}
Brotli implements both the Compressor and Decompressor interfaces, facilitating the compression and decompression of data streams using the brotli data format specification.
func NewBrotli ¶
func NewBrotli() *Brotli
NewBrotli returns a new Brotli instance, ready to compress and decompress data streams.
type Bzip2 ¶
type Bzip2 struct {
*CompressionLevel
}
Bzip2 implements both the Compressor and Decompressor interfaces, facilitating the compression and decompression of data streams using the bzip2 data format specification.
func NewBzip2 ¶
func NewBzip2() *Bzip2
NewBzip2 returns a new Bzip2 instance, ready to compress and decompress data streams.
type CompressionLevel ¶
type CompressionLevel struct {
// contains filtered or unexported fields
}
CompressionLevel is a helper struct to allow for easy implementation of the Leveller interface.
func (*CompressionLevel) Level ¶
func (c *CompressionLevel) Level() int
Level returns the compression level
func (*CompressionLevel) MaxLevel ¶
func (c *CompressionLevel) MaxLevel() int
MaxLevel returns the maximum supported compression level.
func (*CompressionLevel) MinLevel ¶
func (c *CompressionLevel) MinLevel() int
MinLevel returns the minimum supported compression level.
func (*CompressionLevel) SetLevel ¶
func (c *CompressionLevel) SetLevel(l int) error
SetLevel sets the compression level to l if it's within the bounds of c.MinLevel() and c.MaxLevel(), returning an error otherwise.
type Compressor ¶
type Compressor interface { // Compress compresses data from r, and writes to w. Compress(r io.Reader, w io.Writer) error }
Compressor is a type that is capable of compressing a data stream provided by an io.Reader, writing the output to an io.Writer.
type CompressorDecompressor ¶
type CompressorDecompressor interface { Compressor Decompressor }
type Decompressor ¶
type Decompressor interface { // Decompress decompresses data from r, and writes to w. Decompress(r io.Reader, w io.Writer) error }
Decompressor is a type that is capable of decompressing a data stream provided by an io.Reader, writing the output to an io.Writer.
type Deflate ¶
type Deflate struct {
*CompressionLevel
}
Deflate implements both the Compressor and Decompressor interfaces, facilitating the compression and decompression of data streams using the Deflate data format specification.
func NewDeflate ¶
func NewDeflate() *Deflate
NewDeflate returns a new Deflate instance, ready to compress and decompress data streams.
type FileCompressor ¶
type FileCompressor struct { CompressorDecompressor // Default file extension Extension string // The name of the compression method Method string }
FileCompressor serves as a wrapper for Compressor/Decompressors, providing util functions for working with files.
func NewFileCompressor ¶
func NewFileCompressor(c CompressorDecompressor, method, extension string) *FileCompressor
NewFileCompressor returns a new FileCompressor instance, ready to compress and decompress files.
func (*FileCompressor) CompressFile ¶
func (f *FileCompressor) CompressFile(input string, dest string) error
CompressFile reads the file from input and writes the compressed data to dest, using the Compress method defined by the Compressor interface.
func (*FileCompressor) DecompressFile ¶
func (f *FileCompressor) DecompressFile(input string, dest string) error
DecompressFile reads the compressed file from input and writes the decompressed data to dest, using the Decompress method defined by the Decompressor interface.
type Gzip ¶
type Gzip struct {
*CompressionLevel
}
Gzip implements both the Compressor and Decompressor interfaces, facilitating the compression and decompression of data streams using the gzip data format specification.
func NewGzip ¶
func NewGzip() *Gzip
NewGzip returns a new Gzip instance, ready to compress and decompress data streams.
type Leveller ¶
Leveller defines the contracts for compression methods that make use of levels should implement in order to allow for the control of the internal compression algorithms compression level.
type Lz4 ¶
type Lz4 struct {
*CompressionLevel
}
Lz4 implements both the Compressor and Decompressor interfaces, facilitating the compression and decompression of data streams using the lz4 data compression algorithm.
func NewLz4 ¶
func NewLz4() *Lz4
NewLz4 returns a new Lz4 instance, ready to compress and decompress data streams.
type Lzma ¶
type Lzma struct{}
Lzma implements both the Compressor and Decompressor interfaces, facilitating the compression and decompression of data streams using the lzma data format specification.
func NewLzma ¶
func NewLzma() *Lzma
NewLzma returns a new Lzma instance, ready to compress and decompress data streams.
type Lzma2 ¶
type Lzma2 struct{}
Lzma2 implements both the Compressor and Decompressor interfaces, facilitating the compression and decompression of data streams using the lzma2 data format specification.
func NewLzma2 ¶
func NewLzma2() *Lzma2
NewLzma2 returns a new Lzma2 instance, ready to compress and decompress data streams.
type Lzo ¶
type Lzo struct{}
Lzo implements both the Compressor and Decompressor interfaces, facilitating the compression and decompression of data streams using the Lzo data format specification.
func NewLzo ¶
func NewLzo() *Lzo
NewLzo returns a new Lzo instance, ready to compress and decompress data streams.
type Snappy ¶
type Snappy struct{}
Snappy implements both the Compressor and Decompressor interfaces, facilitating the compression and decompression of data streams using the snappy data compression algorithm.
func NewSnappy ¶
func NewSnappy() *Snappy
NewSnappy returns a new Snappy instance, ready to compress and decompress data streams.
type Xz ¶
type Xz struct{}
Xz implements both the Compressor and Decompressor interfaces, facilitating the compression and decompression of data streams using the Xz data format specification.
func NewXz ¶
func NewXz() *Xz
NewXz returns a new Xz instance, ready to compress and decompress data streams.
type Zlib ¶
type Zlib struct {
*CompressionLevel
}
Zlib implements both the Compressor and Decompressor interfaces, facilitating the compression and decompression of data streams using the zlib data format specification.
func NewZlib ¶
func NewZlib() *Zlib
NewZlib returns a new Zlib instance, ready to compress and decompress data streams.
type Zstd ¶
type Zstd struct{}
Zstd implements both the Compressor and Decompressor interfaces, facilitating the compression and decompression of data streams using the zstd data format specification.
func NewZstd ¶
func NewZstd() *Zstd
NewZstd returns a new Zstd instance, ready to compress and decompress data streams.