copper scaffold:pkg, scaffold:router, and scaffold:queries maintain it for you, and copper run regenerates it on every build.
Wire Modules
Each package declares what it provides in awire.go file:
pkg/rockets/wire.go
wire.Struct(new(NewSvcParams), "*") line tells wire to fill every field of the params struct from the dependency graph. This params struct convention is used throughout Copper:
Composing Modules
pkg/app/wire.go is the composition root for your packages. copper scaffold:pkg adds each new package’s module to it, alongside a few app-level providers:
pkg/app/wire.go
Binding Interfaces
If you would like to depend on an interface rather than a concrete type, add awire.Bind:
Telemetry and receive the satellite implementation. If you decide to swap implementations later, it is a one-line change.
Regenerating
Wire output is generated intowire_gen.go files, which are checked in. copper run and copper build regenerate them automatically. If you would like to run the generator manually:
Wire errors can look intimidating, but they almost always say one of two things: a type has no provider (a constructor or module is missing from a wire set) or has two providers (the same type is provided in two modules). Read the first error, find the type it names, and check your
WireModules for it.