This repository was archived by the owner on Aug 25, 2025. It is now read-only.

Description
Is your feature request related to a problem? Please describe.
wire.FieldsOf is a useful function to inject Fields from a struct. But it needs all the fields to be explicitly listed.
If the Struct only has public fields and all of them have to be injected, there should be an easy way to state it.
For example. I have an application that loads config from YAML to Config struct. Its purpose is only a holder of the configuration (loaded from the environment). Initialization looks like below
type Config struct {
App *app.Config
Auth *auth.Config
Router *router.Config
Logger *logger.Config
HTTPServer *httpserver.Config
}
var New = wire.NewSet(
LoadConfigFromEnv,
wire.FieldsOf(
new(*Config),
"App",
"Auth",
"Logger",
"HTTPServer",
"Router",
),
)
Describe the solution you'd like
Create a public API function wire.AllFieldsOf. So that declaration becomes.
var New = wire.NewSet(
LoadConfigFromEnv,
wire.AllFieldsOf(new(*Config)),
)
Describe alternatives you've considered
The alternative is of course to list the fields as it is done currently