compression

package
v0.16.6 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HuffmanOnly        = gzip.HuffmanOnly
	NoCompression      = gzip.NoCompression
	BestSpeed          = gzip.BestSpeed
	BestCompression    = gzip.BestCompression
	DefaultCompression = gzip.DefaultCompression
)

Gzip compression levels, re-exported so callers don't depend on the backing gzip implementation.

View Source
const NoLimit int64 = math.MaxInt64

NoLimit disables the decompressed-size bound in Gzip64Decode.

Variables

View Source
var ErrWriterNotAcquired = errors.New("using writer after release")

Functions

func Gzip64Decode

func Gzip64Decode(data string, maxDecompressedSize int64) ([]byte, error)

Gzip64Decode decompress data with a size limit of `maxDecompressedSize`. If decoded data turns out to be bigger an error is retured. Use NoLimit for unbounded decompression.

func Gzip64Encode

func Gzip64Encode(data []byte) (string, error)

Gzip64Encode encodes data with default compression

Types

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer is a pooled gzip writer. Its gzip writer is permanently wired to proxy, which forwards writes to the caller's dst while the writer is acquired. The indirection lets Release detach the caller's destination in O(1) instead of paying a second flate reset just to re-point the gzip writer at io.Discard.

func GzipWriter

func GzipWriter(dst io.Writer) *Writer

GzipWriter returns a gzip writer reset onto `dst`, compressing at the default level. Once used, it should be sent back to the pool via `Release`

func GzipWriterLevel

func GzipWriterLevel(dst io.Writer, level int) *Writer

GzipWriterLevel returns a gzip writer reset onto `dst`, compressing at `level`. Once used, it should be sent back to the pool via `Release`

func (*Writer) Close

func (w *Writer) Close() error

func (*Writer) Flush

func (w *Writer) Flush() error

func (*Writer) Release

func (w *Writer) Release()

Release returns the writer to the pool

func (*Writer) Write

func (w *Writer) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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