compression

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package compression provides data compression and decompression using Zstd and S2 algorithms.

Example (RoundTrip)
package main

import (
	"fmt"

	"github.com/verygoodsoftwarenotvirus/platform/v2/compression"
)

func main() {
	c, err := compression.NewCompressor("zstd")
	if err != nil {
		panic(err)
	}

	original := []byte("hello, world!")
	compressed, err := c.CompressBytes(original)
	if err != nil {
		panic(err)
	}

	decompressed, err := c.DecompressBytes(compressed)
	if err != nil {
		panic(err)
	}

	fmt.Println(string(decompressed))
}
Output:
hello, world!

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidAlgorithm is returned when an unsupported compression algorithm is requested.
	ErrInvalidAlgorithm = errors.New("invalid compression algorithm")
)

Functions

This section is empty.

Types

type Compressor

type Compressor interface {
	CompressBytes(in []byte) ([]byte, error)
	DecompressBytes(in []byte) ([]byte, error)
}

Compressor compresses and decompresses byte slices.

func NewCompressor

func NewCompressor(a algo) (Compressor, error)

NewCompressor returns a new Compressor.

Jump to

Keyboard shortcuts

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