gompress

package module
v0.0.0-...-4632a24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2021 License: MIT Imports: 15 Imported by: 0

README

gompress


GitHub release (latest by date including pre-releases) GoDoc reference GitHub GitHub go.mod Go version GitHub Workflow Status

gompress is a small CLI utility for working with compressed data formats.

Supported compression formats
  • brotli
  • bzip2
  • gzip
  • lz4
  • lzma
  • lzma2
  • lzo (64bit only)
  • snappy
  • xz
  • zlib
  • zstd

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.

func (*Brotli) Compress

func (br *Brotli) Compress(r io.Reader, w io.Writer) error

Compress implements the Compressor interface by wrapping w with brotli.NewWriterLevel, which is then used to copy data from r, compressing the data as it's copied.

func (*Brotli) Decompress

func (br *Brotli) Decompress(r io.Reader, w io.Writer) error

Decompress implements the Decompressor interface by wrapping r with brotli.NewReader, which is then used to copy data from r compressing the data as it's copied.

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.

func (*Bzip2) Compress

func (b *Bzip2) Compress(r io.Reader, w io.Writer) error

Compress implements the Compressor interface by wrapping w with bzip2.NewWriter, which is then used to copy data from r, compressing the data as it's copied.

func (*Bzip2) Decompress

func (b *Bzip2) Decompress(r io.Reader, w io.Writer) error

Decompress implements the Decompressor interface by wrapping r with bzip2.NewReader, which is then used to copy data to w, decompressing the data as it's copied.

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.

func (*Deflate) Compress

func (b *Deflate) Compress(r io.Reader, w io.Writer) error

Compress implements the Compressor interface by wrapping w with Deflate.NewWriter, which is then used to copy data from r, compressing the data as it's copied.

func (*Deflate) Decompress

func (b *Deflate) Decompress(r io.Reader, w io.Writer) error

Decompress implements the Decompressor interface by wrapping r with Deflate.NewReader, which is then used to copy data to w, decompressing the data as it's copied.

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.

func (*Gzip) Compress

func (g *Gzip) Compress(r io.Reader, w io.Writer) error

Compress implements the Compressor interface by wrapping w with gzip.NewWriterLevel, which is then used to copy data from r, compressing the data as it's copied.

func (*Gzip) Decompress

func (g *Gzip) Decompress(r io.Reader, w io.Writer) error

Decompress implements the Decompressor interface by wrapping r with gzip.NewReader, which is then used to copy data to w, decompressing the data as it's copied.

type Leveller

type Leveller interface {
	Level() int
	MinLevel() int
	MaxLevel() int
	SetLevel(level int) error
}

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.

func (*Lz4) Compress

func (l *Lz4) Compress(r io.Reader, w io.Writer) error

Compress implements the Compressor interface by wrapping w with lz4.NewWriter, which is then used to copy data from r, compressing the data as it's copied.

func (*Lz4) Decompress

func (l *Lz4) Decompress(r io.Reader, w io.Writer) error

Decompress implements the Decompressor interface by wrapping r with lz4.NewReader, which is then used to copy data from r compressing the data as it's copied.

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.

func (*Lzma) Compress

func (l *Lzma) Compress(r io.Reader, w io.Writer) error

Compress implements the Compressor interface by wrapping w with lzma.NewWriter, which is then used to copy data from r, compressing the data as it's copied.

func (*Lzma) Decompress

func (l *Lzma) Decompress(r io.Reader, w io.Writer) error

Decompress implements the Decompressor interface by wrapping r with lzma.NewReader, which is then used to copy data to w, decompressing the data as it's copied.

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.

func (*Lzma2) Compress

func (l *Lzma2) Compress(r io.Reader, w io.Writer) error

Compress implements the Compressor interface by wrapping w with lzma.NewWriter2, which is then used to copy data from r, compressing the data as it's copied.

func (*Lzma2) Decompress

func (l *Lzma2) Decompress(r io.Reader, w io.Writer) error

Decompress implements the Decompressor interface by wrapping r with lzma.NewReader2, which is then used to copy data to w, decompressing the data as it's copied.

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.

func (*Lzo) Compress

func (l *Lzo) Compress(r io.Reader, w io.Writer) error

Compress implements the Compressor interface by wrapping w with Lzo.NewWriter, which is then used to copy data from r, compressing the data as it's copied.

func (*Lzo) Decompress

func (l *Lzo) Decompress(r io.Reader, w io.Writer) error

Decompress implements the Decompressor interface by wrapping r with Lzo.NewReader, which is then used to copy data to w, decompressing the data as it's copied.

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.

func (*Snappy) Compress

func (s *Snappy) Compress(r io.Reader, w io.Writer) error

Compress implements the Compressor interface by wrapping w with snappy.NewBufferedWriter, which is then used to copy data from r, compressing the data as it's copied.

func (*Snappy) Decompress

func (s *Snappy) Decompress(r io.Reader, w io.Writer) error

Decompress implements the Decompressor interface by wrapping r with snappy.NewReader, which is then used to copy data to w, decompressing the data as it's copied.

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.

func (*Xz) Compress

func (x *Xz) Compress(r io.Reader, w io.Writer) error

Compress implements the Compressor interface by wrapping w with xz.NewWriter, which is then used to copy data from r, compressing the data as it's copied.

func (*Xz) Decompress

func (x *Xz) Decompress(r io.Reader, w io.Writer) error

Decompress implements the Decompressor interface by wrapping r with xz.NewReader, which is then used to copy data to w, decompressing the data as it's copied.

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.

func (*Zlib) Compress

func (z *Zlib) Compress(r io.Reader, w io.Writer) error

Compress implements the Compressor interface by wrapping w with zlib.NewWriter, which is then used to copy data from r, compressing the data as it's copied.

func (*Zlib) Decompress

func (z *Zlib) Decompress(r io.Reader, w io.Writer) error

Decompress implements the Decompressor interface by wrapping r with zlib.NewReader, which is then used to copy data to w, decompressing the data as it's copied.

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.

func (*Zstd) Compress

func (z *Zstd) Compress(r io.Reader, w io.Writer) error

Compress implements the Compressor interface by wrapping w with zstd.NewWriter, which is then used to copy data from r, compressing the data as it's copied.

func (*Zstd) Decompress

func (z *Zstd) Decompress(r io.Reader, w io.Writer) error

Decompress implements the Decompressor interface by wrapping r with zstd.NewReader, which is then used to copy data to w, decompressing the data as it's copied.

Directories

Path Synopsis
cmd
gompress
gompress provides a CLI interface for the gompress package.
gompress provides a CLI interface for the gompress package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL