compressutil

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2018 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Byte value used as canary when using Gzip format
	CompressionCanaryGzip byte = 'G'

	// Byte value used as canary when using Lzw format
	CompressionCanaryLzw byte = 'L'

	// Byte value used as canary when using Snappy format
	CompressionCanarySnappy byte = 'S'

	CompressionTypeLzw = "lzw"

	CompressionTypeGzip = "gzip"

	CompressionTypeSnappy = "snappy"
)

Variables

This section is empty.

Functions

func Compress

func Compress(data []byte, config *CompressionConfig) ([]byte, error)

Compress places the canary byte in a buffer and uses the same buffer to fill in the compressed information of the given input. The configuration supports two type of compression: LZW and Gzip. When using Gzip compression format, if GzipCompressionLevel is not specified, the 'gzip.DefaultCompression' will be assumed.

func Decompress

func Decompress(data []byte) ([]byte, bool, error)

Decompress checks if the first byte in the input matches the canary byte. If the first byte is a canary byte, then the input past the canary byte will be decompressed using the method specified in the given configuration. If the first byte isn't a canary byte, then the utility returns a boolean value indicating that the input was not compressed.

Types

type CompressionConfig

type CompressionConfig struct {
	// Type of the compression algorithm to be used
	Type string

	// When using Gzip format, the compression level to employ
	GzipCompressionLevel int
}

CompressionConfig is used to select a compression type to be performed by Compress and Decompress utilities. Supported types are: * CompressionTypeLzw * CompressionTypeGzip * CompressionTypeSnappy

When using CompressionTypeGzip, the compression levels can also be chosen: * gzip.DefaultCompression * gzip.BestSpeed * gzip.BestCompression

type SnappyReadCloser added in v0.8.0

type SnappyReadCloser struct {
	*snappy.Reader
}

SnappyReadCloser embeds the snappy reader which implements the io.Reader interface. The decompress procedure in this utility expects an io.ReadCloser. This type implements the io.Closer interface to retain the generic way of decompression.

func (*SnappyReadCloser) Close added in v0.8.0

func (s *SnappyReadCloser) Close() error

Close is a noop method implemented only to satisfy the io.Closer interface

Jump to

Keyboard shortcuts

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