compression

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: AGPL-3.0 Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

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

Example (RoundTrip)
package main

import (
	"fmt"

	"github.com/verygoodsoftwarenotvirus/platform/v3/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