# README
This package is a brotli compressor and decompressor implemented in Go.
It was translated from the reference implementation (https://github.com/google/brotli)
with the c2go
tool at https://github.com/andybalholm/c2go.
I have been working on new compression algorithms (not translated from C) in the matchfinder package. You can use them with the NewWriterV2 function. Currently they give better results than the old implementation (at least for compressing my test file, Newton’s Opticks) on levels 2 to 6.
I am using it in production with https://github.com/andybalholm/redwood.
API documentation is found at https://pkg.go.dev/github.com/andybalholm/brotli?tab=doc.
# Packages
The matchfinder package defines reusable components for data compression.
# Functions
HTTPCompressor chooses a compression method (brotli, gzip, or none) based on the Accept-Encoding header, sets the Content-Encoding header, and returns a WriteCloser that implements that compression.
NewReader creates a new Reader reading the given reader.
Writes to the returned writer are compressed and written to dst.
NewWriterLevel is like NewWriter but specifies the compression level instead of assuming DefaultCompression.
NewWriterOptions is like NewWriter but specifies WriterOptions.
NewWriterV2 is like NewWriterLevel, but it uses the new implementation based on the matchfinder package.
# Structs
An Encoder implements the matchfinder.Encoder interface, writing in Brotli format.
WriterOptions configures Writer.