etcd — Dependencies#
Module info#
- Module:
go.etcd.io/etcd/v3(root workspace module) - Go version: 1.26 (toolchain go1.26.1 — cutting-edge)
- Direct dependencies (root go.mod): 21 (includes internal sibling modules)
- Indirect dependencies (root go.sum entries): 214 lines (~107 unique modules, each appears twice)
- Workspace structure: 13 modules in a Go workspace; each has its own go.mod with independent dependency sets
Note on counting: Because etcd is a multi-module workspace, the meaningful dependency count is per-module. The root go.mod is a convenience aggregation. The heaviest module is
server/with ~35 direct dependencies.
Dependency categories#
Core infrastructure#
| Package | Version | Used in | Purpose |
|---|---|---|---|
go.uber.org/zap | v1.27.1 | all modules | Structured logging. Most-used third-party package in the codebase (121 import occurrences in server/ alone). Chosen over stdlib log for performance and structured fields in high-throughput scenarios. |
github.com/spf13/cobra | v1.10.2 | server, etcdctl, pkg | CLI framework for etcd server flags and etcdctl/etcdutl commands. |
github.com/spf13/pflag | v1.0.10 | etcdctl, pkg | POSIX/GNU flag parsing (cobra dependency and used directly). |
github.com/coreos/go-semver | v0.3.1 | server, client, api | Semantic version parsing for cluster version negotiation and compatibility checks. |
github.com/dustin/go-humanize | v1.0.1 | server, etcdctl | Human-readable numbers/sizes in output. |
gopkg.in/natefinch/lumberjack.v2 | v2.2.1 | server | Log rotation for the WAL and server logs. |
go.etcd.io/gofail | v0.2.0 | server (indirect) | Fault injection framework for testing failure scenarios — a etcd-maintained tool for chaos testing. |
Networking / RPC#
| Package | Version | Used in | Purpose |
|---|---|---|---|
google.golang.org/grpc | v1.79.3 | server, client/v3, api, etcdctl | Core transport layer. The entire etcd API is gRPC-first. |
google.golang.org/protobuf | v1.36.11 | server, api | Protobuf message serialization for wire format. |
github.com/golang/protobuf | v1.5.4 | server, api | Legacy protobuf API bridge (kept for gogo/protobuf compatibility). |
github.com/gogo/protobuf | v1.3.2 | server | High-performance protobuf used inside the Raft log encoding (performance-critical path). |
github.com/grpc-ecosystem/grpc-gateway/v2 | v2.28.0 | server, api | Translates REST/HTTP+JSON calls into gRPC, providing the v3 HTTP API. |
github.com/grpc-ecosystem/go-grpc-middleware/v2 | v2.3.3 | server, client | gRPC interceptor chains for auth, logging, retry, and timeout. |
github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus | v1.1.0 | server, client | Prometheus metrics for gRPC calls. |
github.com/soheilhy/cmux | v0.1.5 | server | Connection multiplexer — lets etcd serve gRPC and HTTP on the same port. |
github.com/tmc/grpc-websocket-proxy | v0.0.0-…` | server | Proxies gRPC-gateway to WebSocket clients (for browser watch streams). |
github.com/gorilla/websocket | v1.5.0 | server (indirect) | WebSocket support (pulled in by grpc-websocket-proxy). |
github.com/xiang90/probing | v0.0.0-…` | server | Health-probe utility for peer-to-peer membership probing in cluster liveness detection. |
github.com/coreos/go-systemd/v22 | v22.7.0 | server, client/pkg | systemd socket activation and journald logging integration. |
Data / Storage#
| Package | Version | Used in | Purpose |
|---|---|---|---|
go.etcd.io/bbolt | v1.4.3 | server | BoltDB — the embedded B-tree storage engine for all persistent data. The only storage backend; there is no pluggable storage interface. |
go.etcd.io/raft/v3 | v3.6.0-beta.0 | server | The extracted Raft consensus library. Etcd owns this repo but it is versioned independently. The server imports raft/v3/raftpb (54 times) and raft/v3 (22 times). |
github.com/google/uuid | v1.6.0 | server (indirect) | UUID generation, likely for member IDs and cluster IDs. |
sigs.k8s.io/yaml | v1.6.0 | server, client | YAML parsing for config files and watch event serialization. Chosen over gopkg.in/yaml.v3 for Kubernetes ecosystem compatibility. |
k8s.io/utils | v0.0.0-… | server, cache | Kubernetes utility functions — used in the new client-side cache module. Reflects Kubernetes as the primary consumer. |
Observability#
| Package | Version | Used in | Purpose |
|---|---|---|---|
github.com/prometheus/client_golang | v1.23.2 | server, client | Prometheus metrics exposition. Server exposes /metrics endpoint. |
github.com/prometheus/client_model | v0.6.2 | server (indirect) | Prometheus data model. |
go.opentelemetry.io/otel | v1.42.0 | server, pkg | OpenTelemetry tracing core. |
go.opentelemetry.io/otel/sdk | v1.42.0 | server | OTel SDK for trace export. |
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc | v1.42.0 | server | OTLP gRPC trace exporter. |
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc | v0.65.0 | server | OTel gRPC interceptors for distributed tracing. |
github.com/jonboulle/clockwork | v0.5.0 | server | Mockable clock abstraction used in tests and timeouts. |
Security#
| Package | Version | Used in | Purpose |
|---|---|---|---|
github.com/golang-jwt/jwt/v5 | v5.3.1 | server | JWT token signing and verification for the RBAC authentication system. |
CLI / Terminal#
| Package | Version | Used in | Purpose |
|---|---|---|---|
github.com/bgentry/speakeasy | v0.2.0 | root, etcdctl | Secure password prompt (hides typing for auth password input). |
github.com/cheggaaa/pb/v3 | v3.1.7 | root, etcdctl | Progress bar for snapshot operations. |
github.com/olekukonko/tablewriter | v1.1.4 | etcdctl | Formatted table output for etcdctl commands. |
github.com/fatih/color | v1.19.0 | etcdctl (indirect) | Terminal color output. |
Testing#
| Package | Version | Used in | Purpose |
|---|---|---|---|
github.com/stretchr/testify | v1.11.1 | all modules | Assertion library. Used heavily — assert and require packages appear 43 and 35 times respectively in server/ imports. |
github.com/google/go-cmp | v0.7.0 | server, cache | Deep equality comparison for tests. Used alongside testify. |
go.uber.org/zap/zaptest | — | server | Zap test logger (65 import occurrences in server tests). |
github.com/sirupsen/logrus | v1.9.4 | server (indirect) | Pulled in transitively (via grpc-gateway or websocket-proxy). Not used directly by etcd code. |
github.com/kylelemons/godebug | v1.1.0 | server (indirect) | Diff utility used in some test assertions. |
Stdlib reliance#
etcd makes heavy use of the Go standard library. In the server/ module:
context(101 files): Ubiquitous for cancellation and deadline propagation across gRPC calls and background goroutines.time(130 files): Critical for election timeouts, heartbeat intervals, lease TTLs, and session management.sync(67 files): Mutex, RWMutex, WaitGroup, Once throughout the server for concurrent state management.fmt/errors: Standard error construction; etcd avoidspkg/errorsand instead uses stdliberrors+fmt.Errorf %w.net/http(45 files): Direct HTTP handler for metrics, health checks, and gRPC-gateway.io/bytes: WAL encoding/decoding and snapshot streaming.encoding/json(28 files): Serialization for config, watch events, and cluster info.path/os: File system access for WAL and snapshot storage.
The project achieves a healthy balance: stdlib handles concurrency, errors, and I/O; third-party handles logging (zap), RPC (grpc/protobuf), and storage (bbolt).
Shared dependencies#
These dependencies are widely used across Go projects and create natural book connection points:
| Dependency | Significance |
|---|---|
go.uber.org/zap | Industry-standard structured logger; used in dozens of major Go projects (Kubernetes, Jaeger, etc.) |
google.golang.org/grpc | Standard gRPC transport; connects etcd to any gRPC-using project |
github.com/spf13/cobra | Ubiquitous CLI framework (~50% of major Go CLIs) |
github.com/prometheus/client_golang | Standard metrics library for the CNCF ecosystem |
github.com/stretchr/testify | Most popular Go test assertion library |
sigs.k8s.io/yaml | Signals Kubernetes-ecosystem alignment |
go.opentelemetry.io/otel | Signals adoption of OTel as the observability standard |
Vendoring#
No vendor directory. etcd uses the module proxy and go.sum checksums for reproducibility. This is the modern approach for projects with strong CI infrastructure; the go.sum file with 214 entries provides integrity guarantees without the disk bloat of vendoring.
Notable dependency decisions#
Two protobuf libraries in parallel: etcd imports both
google.golang.org/protobuf(modern) andgithub.com/gogo/protobuf(high-performance). The gogo variant is used for Raft log entries where serialization is on the critical path; the Google variant is used for the API layer. This pragmatic split prioritizes performance in the hot path.Raft as an external module (
go.etcd.io/raft/v3): The consensus algorithm — etcd’s most distinctive component — is versioned independently from the server. This enables other projects to embed Raft without taking a dependency on the etcd server. The import count (raftpb54 times,raft/v322 times) shows deep integration.bbolt as the sole storage backend: Unlike databases that abstract over multiple storage engines, etcd commits entirely to bbolt (the maintained fork of BoltDB). The MVCC layer is built on top of bbolt’s B-tree, not behind a pluggable interface. This simplicity-over-flexibility choice reflects etcd’s correctness-first philosophy.
OpenTelemetry stack (not Jaeger directly): etcd uses OTel’s vendor-neutral API for tracing, exporting via OTLP. This is a deliberate ecosystem alignment choice — consumers can route traces to any backend without modifying etcd.
k8s.io/utilsin the cache module: The presence of a Kubernetes utility package in the new client-side cache module directly acknowledges Kubernetes as the primary consumer. This is unusual: most libraries avoid dependencies on their own consumers.go.etcd.io/gofail: etcd maintains its own fault-injection library and uses it in server code. This is a sophisticated testing dependency that enables controlled failure injection in production code paths, underscoring the project’s commitment to robustness testing.Minimal client dependency surface: The
client/v3module has only 9 direct external dependencies (zap, testify, grpc, protobuf, semver, humanize, prometheus, grpc-middleware). This disciplined surface means embedding the etcd client in a Go application adds a manageable transitive dependency tree.