VictoriaMetrics/vendor/github.com/valyala/gozstd
2023-05-10 02:15:22 -07:00
..
.gitignore
.travis.yml vendor: upgrade github.com/valyala/gozstd from v1.7.1 to v1.8.3 2020-08-15 15:11:50 +03:00
dict.go
doc.go
gozstd.go vendor: update github.com/valyala/gozstd from v1.13.0 to v1.14.1 2021-10-16 19:14:07 +03:00
libzstd_darwin_amd64.a vendor: update github.com/valyala/gozstd from v1.19.1 to v1.20.1 2023-05-10 02:15:22 -07:00
libzstd_darwin_amd64.go
libzstd_darwin_arm64.a vendor: update github.com/valyala/gozstd from v1.19.1 to v1.20.1 2023-05-10 02:15:22 -07:00
libzstd_darwin_arm64.go vendor: update github.com/valyala/gozstd from v1.10.0 to v1.11.0 2021-05-24 05:00:53 +03:00
libzstd_freebsd_amd64.a vendor: update github.com/valyala/gozstd from v1.19.0 to v1.19.1 2023-04-10 11:30:26 -07:00
libzstd_freebsd_amd64.go
libzstd_illumos_amd64.a vendor: update github.com/valyala/gozstd from v1.19.0 to v1.19.1 2023-04-10 11:30:26 -07:00
libzstd_illumos_amd64.go vendor: update github.com/valyala/gozstd from v1.19.0 to v1.19.1 2023-04-10 11:30:26 -07:00
libzstd_linux_amd64.a vendor: update github.com/valyala/gozstd from v1.18.0 to v1.19.0 2023-04-05 20:55:57 -07:00
libzstd_linux_amd64.go vendor: update github.com/valyala/gozstd from v1.12.0 to v1.13.0 2021-09-22 20:06:52 +03:00
libzstd_linux_arm64.a vendor: update github.com/valyala/gozstd from v1.19.1 to v1.20.1 2023-05-10 02:15:22 -07:00
libzstd_linux_arm64.go vendor: update github.com/valyala/gozstd from v1.15.1 to v1.16.0 2022-02-07 18:31:13 +02:00
libzstd_linux_arm.a vendor: update github.com/valyala/gozstd from v1.19.1 to v1.20.1 2023-05-10 02:15:22 -07:00
libzstd_linux_arm.go
libzstd_linux_musl_amd64.a vendor: update github.com/valyala/gozstd from v1.19.1 to v1.20.1 2023-05-10 02:15:22 -07:00
libzstd_linux_musl_amd64.go vendor: update github.com/valyala/gozstd from v1.12.0 to v1.13.0 2021-09-22 20:06:52 +03:00
libzstd_linux_musl_arm64.a vendor: update github.com/valyala/gozstd from v1.19.1 to v1.20.1 2023-05-10 02:15:22 -07:00
libzstd_linux_musl_arm64.go vendor: update github.com/valyala/gozstd from v1.15.1 to v1.16.0 2022-02-07 18:31:13 +02:00
libzstd_windows_amd64.a vendor: update github.com/valyala/gozstd from v1.19.1 to v1.20.1 2023-05-10 02:15:22 -07:00
libzstd_windows_amd64.go
LICENSE
Makefile vendor: update github.com/valyala/gozstd from v1.19.1 to v1.20.1 2023-05-10 02:15:22 -07:00
reader.go vendor: update github.com/valyala/gozstd from v1.17.0 to v1.18.0 2023-02-18 13:55:27 -08:00
README.md vendor: update github.com/valyala/gozstd from v1.19.1 to v1.20.1 2023-05-10 02:15:22 -07:00
stream.go
writer.go vendor: update github.com/valyala/gozstd from v1.9.0 to v1.10.0 2021-05-17 01:41:51 +03:00
zdict.h vendor: update github.com/valyala/gozstd from v1.17.0 to v1.18.0 2023-02-18 13:55:27 -08:00
zstd_errors.h vendor: update github.com/valyala/gozstd from v1.17.0 to v1.18.0 2023-02-18 13:55:27 -08:00
zstd.h vendor: update github.com/valyala/gozstd from v1.18.0 to v1.19.0 2023-04-05 20:55:57 -07:00

Build Status GoDoc Go Report codecov

gozstd - go wrapper for zstd

Features

  • Vendors upstream zstd without any modifications.

  • Simple API.

  • Optimized for speed. The API may be easily used in zero allocations mode.

  • Compress* and Decompress* functions are optimized for high concurrency.

  • Proper Writer.Flush for network apps.

  • Supports the following features from upstream zstd:

    • Block / stream compression / decompression with all the supported compression levels and with dictionary support.
    • Dictionary building from a sample set. The created dictionary may be saved to persistent storage / transfered over the network.
    • Dictionary loading for compression / decompression.

    Pull requests for missing upstream zstd features are welcome.

Quick start

How to install gozstd?

go get -u github.com/valyala/gozstd

How to compress data?

The easiest way is just to use Compress:

	compressedData := Compress(nil, data)

There is also StreamCompress and Writer for stream compression.

How to decompress data?

The easiest way is just to use Decompress:

	data, err := Decompress(nil, compressedData)

There is also StreamDecompress and Reader for stream decompression.

How to cross-compile gozstd?

If you're cross-compiling some code that uses gozstd and you stumble upon the following error:

# github.com/valyala/gozstd
/go/pkg/mod/github.com/valyala/gozstd@v1.6.2/stream.go:31:59: undefined: CDict
/go/pkg/mod/github.com/valyala/gozstd@v1.6.2/stream.go:35:64: undefined: CDict
/go/pkg/mod/github.com/valyala/gozstd@v1.6.2/stream.go:47:20: undefined: Writer

You can easily fix it by enabling CGO and using a cross-compiler (e.g. arm-linux-gnueabi-gcc):

env CC=arm-linux-gnueabi-gcc GOOS=linux GOARCH=arm CGO_ENABLED=1 go build ./main.go 

NOTE: Check #21 for more info.

Who uses gozstd?

FAQ

  • Q: Which go version is supported? A: go1.10 and newer. Pull requests for older go versions are accepted.

  • Q: Which platforms/architectures are supported? A: linux/amd64, linux/arm, linux/arm64, freebsd/amd64, darwin/amd64, darwin/arm64, windows/amd64. Pull requests for other platforms/architectures are accepted.

  • Q: I don't trust libzstd*.a binary files from the repo or these files dont't work on my OS/ARCH. How to rebuild them? A: Just run make clean libzstd.a if your OS/ARCH is supported.

  • Q: How do I specify custom build flags when recompiling libzstd*.a? A: You can specify MOREFLAGS=... variable when running make like this: MOREFLAGS=-fPIC make clean libzstd.a.

  • Q: Why the repo contains libzstd*.a binary files?
    A: This simplifies package installation with go get without the need to perform additional steps for building the libzstd*.a.