High-performance Go bindings for the ZXC asymmetric compressor, optimised for fast decompression.
Designed for Write Once, Read Many workloads like ML datasets, game assets, and caches.
- Blazing fast decompression - ZXC is specifically optimised for read-heavy workloads.
- Buffer API - compress/decompress
[]byteslices in a single call. - Streaming API - multi-threaded file compression/decompression.
- Functional options - clean, composable configuration (
WithLevel,WithChecksum,WithThreads). - Typed errors - sentinel error values for every ZXC error code.
Build the ZXC core library as a static library:
cd /path/to/zxc
cmake -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF \
-DZXC_BUILD_CLI=OFF -DZXC_BUILD_TESTS=OFF
cmake --build buildgit clone https://github.com/hellobertrand/zxc.git
cd zxc/wrappers/go
CGO_ENABLED=1 CGO_LDFLAGS="-L../../build -lzxc -lpthread" go build ./...package main
import (
"fmt"
"log"
zxc "github.com/hellobertrand/zxc/wrappers/go"
)
func main() {
data := []byte("Hello, ZXC from Go!")
// Compress
compressed, err := zxc.Compress(data, zxc.WithLevel(zxc.LevelDefault))
if err != nil {
log.Fatal(err)
}
fmt.Printf("Compressed %d => %d bytes\n", len(data), len(compressed))
// Decompress
original, err := zxc.Decompress(compressed)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Decompressed: %s\n", original)
}// Multi-threaded file compression
n, err := zxc.CompressFile("input.bin", "output.zxc",
zxc.WithLevel(zxc.LevelCompact),
zxc.WithThreads(4),
zxc.WithChecksum(true),
)
// Decompress
n, err = zxc.DecompressFile("output.zxc", "restored.bin")cd zxc/wrappers/go
CGO_ENABLED=1 CGO_LDFLAGS="-L../../build -lzxc -lpthread" go test -v -count=1 ./...CGO_ENABLED=1 CGO_LDFLAGS="-L../../build -lzxc -lpthread" go test -bench=. -benchmem ./...BSD-3-Clause - see LICENSE.