MCPcopy
hub / github.com/klauspost/compress

github.com/klauspost/compress @v1.19.0 sqlite

repository ↗ · DeepWiki ↗ · release v1.19.0 ↗
2,483 symbols 12,380 edges 216 files 1,083 documented · 44%
README

compress

This package provides various compression algorithms.

  • zstandard compression and decompression in pure Go.
  • S2 is a high performance replacement for Snappy.
  • Optimized deflate packages which can be used as a dropin replacement for gzip, zip and zlib.
  • snappy is a drop-in replacement for github.com/golang/snappy offering better compression and concurrent streams.
  • huff0 and FSE implementations for raw entropy encoding.
  • gzhttp Provides client and server wrappers for handling gzipped/zstd HTTP requests efficiently.
  • pgzip is a separate package that provides a very fast parallel gzip implementation.

Go Reference Go Sourcegraph Badge

package usage

Use go get github.com/klauspost/compress@latest to add it to your project.

This package will support the current Go version and 2 versions back.

  • Use the nounsafe tag to disable all use of the "unsafe" package.
  • Use the noasm tag to disable all assembly across packages.

Use the links above for more information on each.

changelog

  • Feb 9th, 2026 1.18.4

    • gzhttp: Add zstandard to server handler wrapper https://github.com/klauspost/compress/pull/1121
    • zstd: Add ResetWithOptions to encoder/decoder https://github.com/klauspost/compress/pull/1122
    • gzhttp: preserve qvalue when extra parameters follow in Accept-Encoding by @analytically in https://github.com/klauspost/compress/pull/1116
  • Jan 16th, 2026 1.18.3

  • Dec 1st, 2025 - 1.18.2

    • flate: Fix invalid encoding on level 9 with single value input in https://github.com/klauspost/compress/pull/1115
    • flate: reduce stateless allocations by @RXamzin in https://github.com/klauspost/compress/pull/1106
  • Oct 20, 2025 - 1.18.1 - RETRACTED

  • zstd: Add simple zstd EncodeTo/DecodeTo functions https://github.com/klauspost/compress/pull/1079
  • zstd: Fix incorrect buffer size in dictionary encodes https://github.com/klauspost/compress/pull/1059
  • s2: check for cap, not len of buffer in EncodeBetter/Best by @vdarulis in https://github.com/klauspost/compress/pull/1080
  • zlib: Avoiding extra allocation in zlib.reader.Reset by @travelpolicy in https://github.com/klauspost/compress/pull/1086
  • gzhttp: remove redundant err check in zstdReader by @ryanfowler in https://github.com/klauspost/compress/pull/1090
  • flate: Faster load+store https://github.com/klauspost/compress/pull/1104
  • flate: Simplify matchlen https://github.com/klauspost/compress/pull/1101
  • flate: Use exact sizes for huffman tables https://github.com/klauspost/compress/pull/1103

  • Feb 19th, 2025 - 1.18.0

  • Add unsafe little endian loaders https://github.com/klauspost/compress/pull/1036
  • fix: check r.err != nil but return a nil value error err by @alingse in https://github.com/klauspost/compress/pull/1028
  • flate: Simplify L4-6 loading https://github.com/klauspost/compress/pull/1043
  • flate: Simplify matchlen (remove asm) https://github.com/klauspost/compress/pull/1045
  • s2: Improve small block compression speed w/o asm https://github.com/klauspost/compress/pull/1048
  • flate: Fix matchlen L5+L6 https://github.com/klauspost/compress/pull/1049
  • flate: Cleanup & reduce casts https://github.com/klauspost/compress/pull/1050

See changes to v1.17.x

  • Oct 11th, 2024 - 1.17.11
  • zstd: Fix extra CRC written with multiple Close calls https://github.com/klauspost/compress/pull/1017
  • s2: Don't use stack for index tables https://github.com/klauspost/compress/pull/1014
  • gzhttp: No content-type on no body response code by @juliens in https://github.com/klauspost/compress/pull/1011
  • gzhttp: Do not set the content-type when response has no body by @kevinpollet in https://github.com/klauspost/compress/pull/1013

  • Sep 23rd, 2024 - 1.17.10

    • gzhttp: Add TransportAlwaysDecompress option. https://github.com/klauspost/compress/pull/978
    • gzhttp: Add supported decompress request body by @mirecl in https://github.com/klauspost/compress/pull/1002
    • s2: Add EncodeBuffer buffer recycling callback https://github.com/klauspost/compress/pull/982
    • zstd: Improve memory usage on small streaming encodes https://github.com/klauspost/compress/pull/1007
    • flate: read data written with partial flush by @vajexal in https://github.com/klauspost/compress/pull/996
  • Jun 12th, 2024 - 1.17.9

    • s2: Reduce ReadFrom temporary allocations https://github.com/klauspost/compress/pull/949
    • flate, zstd: Shave some bytes off amd64 matchLen by @greatroar in https://github.com/klauspost/compress/pull/963
    • Upgrade zip/zlib to 1.22.4 upstream https://github.com/klauspost/compress/pull/970 https://github.com/klauspost/compress/pull/971
    • zstd: BuildDict fails with RLE table https://github.com/klauspost/compress/pull/951
  • Apr 9th, 2024 - 1.17.8

    • zstd: Reject blocks where reserved values are not 0 https://github.com/klauspost/compress/pull/885
    • zstd: Add RLE detection+encoding https://github.com/klauspost/compress/pull/938
  • Feb 21st, 2024 - 1.17.7

    • s2: Add AsyncFlush method: Complete the block without flushing by @Jille in https://github.com/klauspost/compress/pull/927
    • s2: Fix literal+repeat exceeds dst crash https://github.com/klauspost/compress/pull/930
  • Feb 5th, 2024 - 1.17.6

    • zstd: Fix incorrect repeat coding in best mode https://github.com/klauspost/compress/pull/923
    • s2: Fix DecodeConcurrent deadlock on errors https://github.com/klauspost/compress/pull/925
  • Jan 26th, 2024 - v1.17.5

    • flate: Fix reset with dictionary on custom window encodes https://github.com/klauspost/compress/pull/912
    • zstd: Add Frame header encoding and stripping https://github.com/klauspost/compress/pull/908
    • zstd: Limit better/best default window to 8MB https://github.com/klauspost/compress/pull/913
    • zstd: Speed improvements by @greatroar in https://github.com/klauspost/compress/pull/896 https://github.com/klauspost/compress/pull/910
    • s2: Fix callbacks for skippable blocks and disallow 0xfe (Padding) by @Jille in https://github.com/klauspost/compress/pull/916 https://github.com/klauspost/compress/pull/917 https://github.com/klauspost/compress/pull/919 https://github.com/klauspost/compress/pull/918
  • Dec 1st, 2023 - v1.17.4

    • huff0: Speed up symbol counting by @greatroar in https://github.com/klauspost/compress/pull/887
    • huff0: Remove byteReader by @greatroar in https://github.com/klauspost/compress/pull/886
    • gzhttp: Allow overriding decompression on transport https://github.com/klauspost/compress/pull/892
    • gzhttp: Clamp compression level https://github.com/klauspost/compress/pull/890
    • gzip: Error out if reserved bits are set https://github.com/klauspost/compress/pull/891
  • Nov 15th, 2023 - v1.17.3

    • fse: Fix max header size https://github.com/klauspost/compress/pull/881
    • zstd: Improve better/best compression https://github.com/klauspost/compress/pull/877
    • gzhttp: Fix missing content type on Close https://github.com/klauspost/compress/pull/883
  • Oct 22nd, 2023 - v1.17.2

    • zstd: Fix rare CORRUPTION output in "best" mode. See https://github.com/klauspost/compress/pull/876
  • Oct 14th, 2023 - v1.17.1

    • s2: Fix S2 "best" dictionary wrong encoding https://github.com/klauspost/compress/pull/871
    • flate: Reduce allocations in decompressor and minor code improvements by @fakefloordiv in https://github.com/klauspost/compress/pull/869
    • s2: Fix EstimateBlockSize on 6&7 length input https://github.com/klauspost/compress/pull/867
  • Sept 19th, 2023 - v1.17.0

    • Add experimental dictionary builder https://github.com/klauspost/compress/pull/853
    • Add xerial snappy read/writer https://github.com/klauspost/compress/pull/838
    • flate: Add limited window compression https://github.com/klauspost/compress/pull/843
    • s2: Do 2 overlapping match checks https://github.com/klauspost/compress/pull/839
    • flate: Add amd64 assembly matchlen https://github.com/klauspost/compress/pull/837
    • gzip: Copy bufio.Reader on Reset by @thatguystone in https://github.com/klauspost/compress/pull/860

See changes to v1.16.x

  • July 1st, 2023 - v1.16.7

    • zstd: Fix default level first dictionary encode https://github.com/klauspost/compress/pull/829
    • s2: add GetBufferCapacity() method by @GiedriusS in https://github.com/klauspost/compress/pull/832
  • June 13, 2023 - v1.16.6

    • zstd: correctly ignore WithEncoderPadding(1) by @ianlancetaylor in https://github.com/klauspost/compress/pull/806
    • zstd: Add amd64 match length assembly https://github.com/klauspost/compress/pull/824
    • gzhttp: Handle informational headers by @rtribotte in https://github.com/klauspost/compress/pull/815
    • s2: Improve Better compression slightly https://github.com/klauspost/compress/pull/663
  • Apr 16, 2023 - v1.16.5

    • zstd: readByte needs to use io.ReadFull by @jnoxon in https://github.com/klauspost/compress/pull/802
    • gzip: Fix WriterTo after initial read https://github.com/klauspost/compress/pull/804
  • Apr 5, 2023 - v1.16.4

    • zstd: Improve zstd best efficiency by @greatroar and @klauspost in https://github.com/klauspost/compress/pull/784
    • zstd: Respect WithAllLitEntropyCompression https://github.com/klauspost/compress/pull/792
    • zstd: Fix amd64 not always detecting corrupt data https://github.com/klauspost/compress/pull/785
    • zstd: Various minor improvements by @greatroar in https://github.com/klauspost/compress/pull/788 https://github.com/klauspost/compress/pull/794 https://github.com/klauspost/compress/pull/795
    • s2: Fix huge block overflow https://github.com/klauspost/compress/pull/779
    • s2: Allow CustomEncoder fallback https://github.com/klauspost/compress/pull/780
    • gzhttp: Support ResponseWriter Unwrap() in gzhttp handler by @jgimenez in https://github.com/klauspost/compress/pull/799
  • Mar 13, 2023 - v1.16.1

    • zstd: Speed up + improve best encoder by @greatroar in https://github.com/klauspost/compress/pull/776
    • gzhttp: Add optional BREACH mitigation. https://github.com/klauspost/compress/pull/762 https://github.com/klauspost/compress/pull/768 https://github.com/klauspost/compress/pull/769 https://github.com/klauspost/compress/pull/770 https://github.com/klauspost/compress/pull/767
    • s2: Add Intel LZ4s converter https://github.com/klauspost/compress/pull/766
    • zstd: Minor bug fixes https://github.com/klauspost/compress/pull/771 https://github.com/klauspost/compress/pull/772 https://github.com/klauspost/compress/pull/773
    • huff0: Speed up compress1xDo by @greatroar in https://github.com/klauspost/compress/pull/774
  • Feb 26, 2023 - v1.16.0

    • s2: Add Dictionary support. https://github.com/klauspost/compress/pull/685
    • s2: Add Compression Size Estimate. https://github.com/klauspost/compress/pull/752
    • s2: Add support for custom stream encoder. https://github.com/klauspost/compress/pull/755
    • s2: Add LZ4 block converter. https://github.com/klauspost/compress/pull/748
    • s2: Support io.ReaderAt in ReadSeeker. https://github.com/klauspost/compress/pull/747
    • s2c/s2sx: Use concurrent decoding. https://github.com/klauspost/compress/pull/746

See changes to v1.15.x

  • Jan 21st, 2023 (v1.15.15)
    • deflate: Improve level 7-9 https://github.com/klauspost/compress/pull/739
    • zstd: Add delta encoding support by @greatroar in https://github.com/klauspost/compress/pull/728
    • zstd: Various speed

Extension points exported contracts — how you extend this code

Resetter (Interface)
Resetter resets a ReadCloser returned by NewReader or NewReaderDict to to switch to a new underlying Reader. This permit [26 …
flate/inflate.go
GzipWriter (Interface)
GzipWriter implements the functions needed for compressing content. [7 implementers]
gzhttp/writer/interface.go
Resetter (Interface)
Resetter resets a ReadCloser returned by [NewReader] or [NewReaderDict] to switch to a new underlying Reader. This permi [26 …
zlib/reader.go
DOption (FuncType)
DOption is an option for creating a decoder.
zstd/decoder_options.go
EOption (FuncType)
EOption is an option for creating a encoder.
zstd/encoder_options.go
Compressor (FuncType)
A Compressor returns a new compressing writer, writing to w. The WriteCloser's Close method must be used to flush pendin
zip/register.go
ReaderOption (FuncType)
ReaderOption is an option for creating a decoder.
s2/reader.go
WriterOption (FuncType)
WriterOption is an option for creating a encoder.
s2/writer.go

Core symbols most depended-on inside this repo

Fatal
called by 1172
flate/token_test.go
Error
called by 410
s2/reader.go
println
called by 261
zstd/zstd.go
Write
called by 238
gzhttp/writer/interface.go
Close
called by 221
gzhttp/writer/interface.go
load64
called by 212
s2/encode_all.go
Bytes
called by 173
s2/s2.go
NewReader
called by 140
zstd/decoder.go

Shape

Function 1,378
Method 835
Struct 215
TypeAlias 26
Interface 18
FuncType 11

Languages

Go100%

Modules by API surface

gzhttp/compress_test.go88 symbols
s2/s2_test.go75 symbols
snappy/snappy_test.go73 symbols
gzhttp/compress.go61 symbols
zip/reader.go60 symbols
zstd/decoder_test.go57 symbols
gzip/gzip_test.go56 symbols
flate/writer_test.go56 symbols
zip/zip_test.go44 symbols
zip/reader_test.go40 symbols
zstd/encoder_test.go39 symbols
flate/inflate.go37 symbols

Dependencies from manifests, versioned

github.com/klauspost/asmfmtv1.3.2 · 1×
golang.org/x/modv0.21.0 · 1×
golang.org/x/syncv0.8.0 · 1×
golang.org/x/toolsv0.25.1 · 1×

For agents

$ claude mcp add compress \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact