Compile-time Dependency Injection With Go Cloud's Wire - The Go Programming Language
Wire is a compile-time dependency injection tool for Go, built for Go Cloud so applications can swap provider-specific implementations (such as S3 vs GCS behind blob.Bucket) without hand-rewriting initialization code. Inspired by Dagger 2 rather than reflection-based injectors like Uber's dig or Facebook's inject, Wire uses providers (ordinary constructor functions) and injector signatures with wire.Build, then generates plain Go initialization code via go generate. Missing dependencies become compile-time errors, there is no runtime dependency on Wire, unused imports are avoided, and the dependency graph is statically knowable for tooling.
Related posts
- Ready, steady, goa: our API setup
incident.io mediumAdeptincident.io defines its HTTP API in Goa's design-first DSL, which generates net/http transport handlers, validation code, typed Go service interfaces, OpenAPI 3.0 specs and Go clients. This replaces hand-written Gin handlers with manual parsing, auth and serialization. On top of Goa, a `make generate-api` pipeline pretty-prints and merges the OpenAPI output and filters it into internal, mobile and public variants. Those variants feed specialised clients: typed TypeScript for the React frontend, lean mobile clients and Go test clients. A single DSL change then flows through to server code, docs and compile-time-checked frontend types.
- Using modules for Testcontainers with Golang
Zalando Engineering mediumAdeptTestcontainers for Go lets integration tests start real dependencies such as Redis in containers, but raw usage requires knowing ports, wait strategies and environment details. Zalando built an internal wrapper library using the Functional Options Pattern to supply per-dependency defaults, then migrated to the official Testcontainers modules, which do the same job and cut maintenance. A common problem is the Ryuk garbage-collector sidecar failing under Podman; it can be fixed by disabling it with TESTCONTAINERS_RYUK_DISABLED or by running Podman rootful with the privileged and Docker socket override variables.
- Engineering nits: Generating code faster
incident.io mediumAdeptincident.io cut a Go code-generation step from about 16 seconds to under half a second (97% faster) by adding commonly used imports directly to the generator's template. The bottleneck was goimports resolving missing imports, which requires scanning every package in the module and its dependencies, repeated hundreds of times. Removing unused imports is cheap because it only inspects a single file, so over-including imports (with the list built via `go list`) leaves goimports little to resolve. The roughly 20-line change saves about 3 engineer-hours per week for a team of around 20.
- One-Second Deploys? We Didn’t Believe It Either
Railway easyNoviceRailway Functions, now generally available, deploy single-file TypeScript code onto Railway's container compute in about a second, without a package.json, Git repo, IaC or container build. The pipeline parses source into an AST to infer dependencies and generates package.json on the fly, with versions pinnable directly in import specifiers. Dependencies are installed with `bun install`, which installs fastify in 500ms compared with over 6s for npm, pnpm and yarn without a lockfile. Bun then runs the TypeScript directly with no transpile or bundle step. Functions share Services' features such as volumes and variables.
- Building a great developer experience at a startup
incident.io mediumAdeptincident.io treats developer experience as leverage for sustaining engineering pace without accruing technical or product debt. Their practices include hot reloading, CI kept under roughly 3 minutes, PR reviews within an hour or two, Slack block-kit previews, and a Go `toolbox` CLI for running code locally or in production. Strong typing across Go and TypeScript is reinforced by a type-safe DB library, goa-generated OpenAPI clients and an exhaustive-enum `assertUnreachable` pattern. Reusable building blocks such as engine conditions, actors and `useMutation` hooks sit alongside debugging aids: per-engineer real GCP dev environments, tracing, Sentry sourcemaps and structured logs linked to traces.