{"id":35085433,"url":"https://github.com/meysam81/go-zxc","last_synced_at":"2026-01-13T21:59:14.974Z","repository":{"id":330845410,"uuid":"1123320766","full_name":"meysam81/go-zxc","owner":"meysam81","description":"Go bindings for ZXC compression. 40% faster decompression than LZ4 on ARM64. Thread-safe, streaming API included.","archived":false,"fork":false,"pushed_at":"2026-01-12T18:05:45.000Z","size":96,"stargazers_count":1,"open_issues_count":4,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-12T23:49:43.280Z","etag":null,"topics":["apple-silicon","arm64","cdn","cgo","compression","compression-library","content-delivery","data-compression","decompression","embedded-systems","firmware","game-development","go","go-library","golang","high-performance","lossless-compression","lz4","performance","streaming"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/meysam81.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"meysam81","patreon":"meysam81","buy_me_a_coffee":"meysam"}},"created_at":"2025-12-26T16:19:15.000Z","updated_at":"2025-12-28T13:39:26.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/meysam81/go-zxc","commit_stats":null,"previous_names":["meysam81/go-zxc"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/meysam81/go-zxc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meysam81%2Fgo-zxc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meysam81%2Fgo-zxc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meysam81%2Fgo-zxc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meysam81%2Fgo-zxc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meysam81","download_url":"https://codeload.github.com/meysam81/go-zxc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meysam81%2Fgo-zxc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28400397,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apple-silicon","arm64","cdn","cgo","compression","compression-library","content-delivery","data-compression","decompression","embedded-systems","firmware","game-development","go","go-library","golang","high-performance","lossless-compression","lz4","performance","streaming"],"created_at":"2025-12-27T13:33:18.048Z","updated_at":"2026-01-13T21:59:14.969Z","avatar_url":"https://github.com/meysam81.png","language":"C++","funding_links":["https://github.com/sponsors/meysam81","https://patreon.com/meysam81","https://buymeacoffee.com/meysam"],"categories":[],"sub_categories":[],"readme":"# go-zxc\n\n[![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/meysam81/go-zxc)](https://github.com/meysam81/go-zxc/blob/main/go.mod)\n[![Go Reference](https://pkg.go.dev/badge/github.com/meysam81/go-zxc.svg)](https://pkg.go.dev/github.com/meysam81/go-zxc)\n[![Go Report Card](https://goreportcard.com/badge/github.com/meysam81/go-zxc?style=flat-square)](https://goreportcard.com/report/github.com/meysam81/go-zxc)\n[![License](https://img.shields.io/badge/license-Apache--2-blue)](LICENSE)\n[![codecov](https://codecov.io/gh/meysam81/go-zxc/graph/badge.svg?token=CJL9KGSWOH)](https://codecov.io/gh/meysam81/go-zxc)\n[![GitHub release](https://img.shields.io/github/v/release/meysam81/go-zxc?style=flat-square)](https://github.com/meysam81/go-zxc/releases)\n[![GitHub Stars](https://img.shields.io/github/stars/meysam81/go-zxc?style=flat-square\u0026logo=github)](https://github.com/meysam81/go-zxc/stargazers)\n[![GitHub Issues](https://img.shields.io/github/issues/meysam81/go-zxc?style=flat-square\u0026logo=github)](https://github.com/meysam81/go-zxc/issues)\n\nGo bindings for [ZXC](https://github.com/hellobertrand/zxc), an asymmetric high-performance lossless compression library.\n\nZXC is designed for \"Write Once, Read Many\" scenarios where compression speed (build-time) is traded for maximum decompression throughput (run-time). This makes it ideal for content delivery, embedded systems, game assets, firmware, and app bundles.\n\n## Key Features\n\n- **+40% faster decompression** than LZ4 on Apple Silicon\n- **+20% faster decompression** than LZ4 on Cloud ARM (Google Axion)\n- **Better compression ratios** than LZ4\n- **Thread-safe** stateless API suitable for concurrent use\n- **Optional checksum** verification for data integrity\n- **Streaming API** for large files with multi-threaded compression/decompression\n\n## Installation\n\n```bash\ngo get -u github.com/meysam81/go-zxc\n```\n\n**NOTE:**: This package is a CGO wrapper and you MUST have `CGO_ENABLED` set to `1` (default) to build and use it.\n\n## Quick Start\n\n### In-Memory Compression\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n\n    \"github.com/meysam81/go-zxc\"\n)\n\nfunc main() {\n    // Original data\n    data := []byte(\"Hello, ZXC! This is a sample text for compression.\")\n\n    // Compress with default options\n    compressed, err := zxc.Compress(data, nil)\n    if err != nil {\n        log.Fatal(err)\n    }\n\n    fmt.Printf(\"Original: %d bytes\\n\", len(data))\n    fmt.Printf(\"Compressed: %d bytes\\n\", len(compressed))\n\n    // Decompress\n    decompressed, err := zxc.Decompress(compressed, len(data), nil)\n    if err != nil {\n        log.Fatal(err)\n    }\n\n    fmt.Printf(\"Decompressed: %s\\n\", string(decompressed))\n}\n```\n\n### Streaming Compression\n\nFor large files that may not fit in memory, use the streaming API:\n\n```go\npackage main\n\nimport (\n    \"log\"\n    \"os\"\n\n    \"github.com/meysam81/go-zxc\"\n)\n\nfunc main() {\n    inputFile, err := os.Open(\"large-file.dat\")\n    if err != nil {\n        log.Fatal(err)\n    }\n    defer inputFile.Close()\n\n    outputFile, err := os.Create(\"large-file.dat.zxc\")\n    if err != nil {\n        log.Fatal(err)\n    }\n    defer outputFile.Close()\n\n    opts := \u0026zxc.StreamOptions{\n        Level:    zxc.LevelDefault,\n        Checksum: true,\n        Threads:  0,\n    }\n\n    compressedBytes, err := zxc.StreamCompress(inputFile, outputFile, opts)\n    if err != nil {\n        log.Fatal(err)\n    }\n\n    log.Printf(\"Compressed %d bytes\\n\", compressedBytes)\n}\n```\n\n## Compression Levels\n\nZXC provides four compression levels with different trade-offs:\n\n| Level | Constant        | Description                                          |\n| ----- | --------------- | ---------------------------------------------------- |\n| 2     | `LevelFast`     | Fastest compression, best for real-time applications |\n| 3     | `LevelDefault`  | Recommended: ratio \u003e LZ4, decode speed \u003e LZ4         |\n| 4     | `LevelBalanced` | Good ratio and decode speed balance                  |\n| 5     | `LevelCompact`  | Highest density, best for storage/firmware/assets    |\n\n```go\n// Use compact level for maximum compression\nopts := \u0026zxc.Options{\n    Level:    zxc.LevelCompact,\n    Checksum: true,\n}\ncompressed, err := zxc.Compress(data, opts)\n```\n\n## API Reference\n\n### Compression\n\n```go\n// Compress data with automatic buffer allocation\ncompressed, err := zxc.Compress(data, opts)\n\n// Compress into a pre-allocated buffer\nn, err := zxc.CompressTo(dst, src, opts)\n\n// Calculate maximum compressed size for pre-allocation\nmaxSize := zxc.CompressBound(len(data))\n```\n\n### Decompression\n\n```go\n// Decompress with known original size\ndecompressed, err := zxc.Decompress(compressed, originalSize, opts)\n\n// Decompress into a pre-allocated buffer\nn, err := zxc.DecompressTo(dst, compressed, opts)\n```\n\n### Streaming Compression\n\n```go\ncompressedBytes, err := zxc.StreamCompress(inputFile, outputFile, streamOpts)\n```\n\nCompresses data from the input file to the output file using a multi-threaded streaming pipeline. Designed for large files that may not fit in memory.\n\n### Streaming Decompression\n\n```go\ndecompressedBytes, err := zxc.StreamDecompress(inputFile, outputFile, streamOpts)\n```\n\nDecompresses data from the input file to the output file using a multi-threaded streaming pipeline.\n\n### Options\n\n```go\ntype Options struct {\n    Level    Level // Compression level (default: LevelDefault)\n    Checksum bool  // Enable checksum (default: true)\n}\n\ntype StreamOptions struct {\n    Level    Level // Compression level (default: LevelDefault)\n    Checksum bool  // Enable checksum (default: true)\n    Threads  int   // Number of worker threads (0 = auto-detect CPU cores)\n}\n```\n\n## Version\n\n```go\nversion := zxc.Version() // Returns \"0.3.0\"\n```\n\n## Error Handling\n\n```go\nvar (\n    ErrCompression          error\n    ErrDecompression        error\n    ErrBufferTooSmall       error\n    ErrInvalidLevel         error\n    ErrEmptyInput           error\n    ErrStreamNilFile        error\n    ErrStreamOpen           error\n    ErrStreamCompression    error\n    ErrStreamDecompression  error\n)\n```\n\n## Thread Safety\n\nAll functions are thread-safe and can be called concurrently from multiple goroutines. The underlying C library uses a stateless design with caller-allocated buffers.\n\n```go\n// Safe for concurrent use\nvar wg sync.WaitGroup\nfor i := 0; i \u003c 100; i++ {\n    wg.Add(1)\n    go func(data []byte) {\n        defer wg.Done()\n        compressed, _ := zxc.Compress(data, nil)\n        // use compressed...\n    }(data)\n}\nwg.Wait()\n```\n\n## Benchmarks\n\nRun benchmarks with:\n\n```bash\ngo test -bench=. -benchmem\n```\n\nExample results:\n\n```shell\n$ go test -bench=. -benchmem\ngoos: linux\ngoarch: amd64\npkg: github.com/meysam81/go-zxc\ncpu: AMD Ryzen 5 3600 6-Core Processor\n```\n\n| Benchmark                           | Iterations | Time per Op   | Throughput   | Allocated  | Allocations |\n| ----------------------------------- | ---------- | ------------- | ------------ | ---------- | ----------- |\n| BenchmarkStreamCompress-12          | 544        | 2121956 ns/op | 212.07 MB/s  | 400 B/op   | 7 allocs/op |\n| BenchmarkStreamDecompress-12        | 524        | 2277227 ns/op | 197.61 MB/s  | 336 B/op   | 6 allocs/op |\n| BenchmarkCompress-12                | 138612     | 8934 ns/op    | 5036.80 MB/s | 49152 B/op | 1 allocs/op |\n| BenchmarkDecompress-12              | 107698     | 10726 ns/op   | 4195.44 MB/s | 49152 B/op | 1 allocs/op |\n| BenchmarkCompressLevels/Fast-12     | 164079     | 8745 ns/op    | 5145.94 MB/s | 49152 B/op | 1 allocs/op |\n| BenchmarkCompressLevels/Default-12  | 146947     | 7705 ns/op    | 5840.28 MB/s | 49152 B/op | 1 allocs/op |\n| BenchmarkCompressLevels/Balanced-12 | 161617     | 8235 ns/op    | 5464.67 MB/s | 49152 B/op | 1 allocs/op |\n| BenchmarkCompressLevels/Compact-12  | 138926     | 8285 ns/op    | 5431.42 MB/s | 49152 B/op | 1 allocs/op |\n\n## Use Cases\n\n### In-Memory Compression\n\nBest for small to medium-sized data that fits in memory. Use `Compress` and `Decompress` functions.\n\n### Streaming Compression\n\nBest for large files (hundreds of MB or larger) that may not fit in memory. The streaming API uses a multi-threaded pipeline with asynchronous I/O to maximize throughput. Use `StreamCompress` and `StreamDecompress` functions.\n\n## License\n\nThis project is licensed under the Apache-2.0 License - see the [LICENSE](LICENSE) file for details.\n\nThe underlying ZXC library is Copyright (c) 2025 Bertrand Lebonnois, also under Apache-2.0.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeysam81%2Fgo-zxc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeysam81%2Fgo-zxc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeysam81%2Fgo-zxc/lists"}