brotli

A pure Go implementation of the Brotli compression algorithm, exposing io.Writer/io.Reader types compatible with Go's standard compression package conventions.

Library
Go
vv1.2.3
732stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
47/100Fair
Development Activity52
Maintenance4
Community44
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
67/100Good
Architecture75
Code Quality58
Innovation78
Learning Curve55

brotli is a pure Go port of Google’s reference Brotli compression library, translated from the original C implementation with the author’s own c2go tool rather than wrapped via cgo bindings. It exposes NewWriter and NewReader constructors that mirror the ergonomics of Go’s standard compress/gzip package, along with tunable WriterOptions for quality and window-size trade-offs across the full BestSpeed-to-BestCompression range.

Beyond the core codec, the library ships an HTTPCompressor helper that negotiates brotli versus gzip versus no compression directly from a request’s Accept-Encoding header, a bundled flate/gzip-compatible subpackage, and an experimental matchfinder package that decouples LZ77 match-finding from entropy coding so custom compression strategies can be composed via the newer NewWriterV2 API.

What You Get

  • Standard-library-style Writer and Reader types for encoding and decoding brotli streams
  • Quality and window-size tunables (WriterOptions) covering the full BestSpeed-to-BestCompression range
  • An HTTP helper (HTTPCompressor) that negotiates brotli vs gzip automatically from request headers
  • A bundled flate/gzip-compatible subpackage for projects that want one dependency covering multiple formats
  • An experimental matchfinder API for composing custom LZ77 and entropy-coding strategies

Common Use Cases

  • Compressing HTTP API and web server responses on the fly
  • Pre-compressing static assets for CDN delivery
  • Replacing cgo-based Brotli bindings in cross-compiled or WASM Go binaries
  • Prototyping custom LZ77 compression strategies via the matchfinder package

Under The Hood

Architecture The library is organized as a flat package translated from Google’s C reference implementation via the author’s c2go tool, with encode.go and decode.go orchestrating state-machine-based encoder and decoder routines, Writer and Reader types in writer.go and reader.go wrapping io.Writer/io.Reader behind a Reset-based reuse pattern, and a family of pluggable hashers (h5.go, h6.go, h10.go, hash_*.go) selected at runtime by chooseHasher() based on the requested quality level. A separate matchfinder subpackage defines MatchFinder and Encoder interfaces that decouple LZ77 match-finding from entropy coding, backing the newer, experimental NewWriterV2 API. Naming and structure still carry visible marks of the C-to-Go translation (globals like octetTypes, struct fields like literal_hgroup and block_type_trees), which keeps the core codec dense but consistent once the state-machine pattern is understood.

Tech Stack The module is pure Go (go.mod targets Go 1.22) with a single non-test dependency, github.com/xyproto/randomstring, used only in the test suite for generating randomized input data. A bundled flate subpackage reimplements drop-in equivalents of the standard library’s compress/flate and compress/gzip writers, and http.go integrates directly with net/http to add Accept-Encoding-based content negotiation to any http.ResponseWriter. There is no cgo dependency anywhere in the codebase, which is the library’s central technical proposition versus bindings to Google’s original C implementation.

Code Quality The repository has three test files — brotli_test.go (over 1,000 lines covering round-trip compression and decompression across quality levels), example_test.go, and flate/flate_test.go — exercising the public API with real corpus-style data. Error handling is idiomatic Go, using sentinel errors (errEncode, errWriterClosed, errExcessiveInput, errInvalidState) rather than panics. No linter configuration (no .golangci.yml) or CI workflow directory is present in the cloned source, so it’s unclear whether tests and vetting are enforced automatically on every change versus run manually by the maintainer before tagging a release.

API Design The public surface deliberately mirrors Go’s standard compress/gzip and compress/flate conventions — NewWriter, NewReader, Reset, Close — so anyone familiar with the standard library can adopt it with almost no new API to learn. HTTPCompressor and HTTPCompressorWithLevel collapse content-negotiation boilerplate into a single call for HTTP handlers, automatically choosing brotli, gzip, or no compression from the Accept-Encoding header. The newer, explicitly experimental NewWriterV2 and matchfinder package expose a lower-level MatchFinder/Encoder interface pair for callers who want to swap in custom LZ77 or entropy-coding strategies, a level of extensibility uncommon among general-purpose compression libraries, though the README is explicit that these newer APIs carry no SemVer compatibility guarantee yet.

Used by 8 apps in this directory

Go
85%
Apache 2.0

Argo Workflows

Devops · Data Engineering

16,943

The most popular Kubernetes-native workflow engine for orchestrating containerized DAGs, ML pipelines, CI/CD, and parallel batch jobs at scale.

View details
95
Repo Health
90
Technical
68
Dependency
Built with
Go85%
TypeScript11%
Updated yesterday
Go
75%
AGPL 3.0

Coder

Devops · Developer Tools · Code Editors

14,299

Self-hosted cloud development environments and AI coding agents — defined in Terraform, connected via WireGuard, automatically shut down when idle.

View details
93
Repo Health
90
Technical
69
Dependency
Built with
Go75%
TypeScript23%
Updated today
Go
92%
AGPL 3.0

Cozy Stack

File Storage · Productivity

1,270

Self-hosted personal cloud platform that unifies your files, apps, and devices in one private space you fully control.

View details
94
Repo Health
77
Technical
67
Dependency
Built with
Go92%
Updated 2 days ago
TypeScript
49%
AGPL 3.0

Grafana

Monitoring · Analytics

76,498

The open-source observability platform that unifies metrics, logs, and traces from any data source into dynamic, queryable dashboards.

View details
95
Repo Health
91
Technical
65
Dependency
Built with
TypeScript49%
Go45%
Updated today
TypeScript
71%
Other

highlight.io

Developer Tools · Analytics · Monitoring

9,373

Open-source full-stack monitoring that unifies session replay, error tracking, logging, and distributed tracing so you can stop context-switching between tools.

View details
70
Repo Health
78
Technical
65
Dependency
Built with
TypeScript71%
Go16%
Updated 1 weeks ago
Go
75%
AGPL 3.0

Teleport

Security · Authentication

20,860

Zero-trust infrastructure access platform that replaces credentials and VPNs with short-lived certificates, SSO, and identity-aware proxies for SSH, Kubernetes, databases, RDP, and AI agents.

View details
94
Repo Health
81
Technical
69
Dependency
Built with
Go75%
TypeScript16%
Updated 2 days ago
Go
93%
MIT

Traefik

Devops · Automation · Security

64,662

A cloud-native reverse proxy and load balancer that auto-configures itself from Docker, Kubernetes, and other orchestrators — zero manual routing required.

View details
93
Repo Health
85
Technical
65
Dependency
Built with
Go93%
Updated today
Go
88%
Apache 2.0

Miniflux

Bookmarks Archiving

9,625

Privacy-first, opinionated feed reader built for speed and control—no bloat, no trackers, no JavaScript overhead.

View details
89
Repo Health
80
Technical
80
Dependency
Built with
Go88%
Updated 6 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search