Description
Is your feature request related to a problem? Please describe.
I am trying to wire a non-pointer field from a struct to a provider which requires a pointer of the same type
Consider the following
type Config struct {
UserConfig UserConfig
}
func initialize(ctx context.Context, cfg *Config) (*st, func(), error) {
panic( // panic to be replaced by generated code
wire.Build(
InitializeUser,
wire.FieldsOf(new(Config), "UserConfig"),
),
)
}
func InitializeUser(config *UserConfig) *User {
// initialize user from user config
}
I am unable to wire the UserConfig
field in my Config
for the InitializeUser
provider without writing a wrapper provider by hand.
Describe the solution you'd like
FieldsOf
should provide both a non-pointer and a pointer type of that field. This seems to already be done today by the Struct Providers
as per the documentation. It would be useful (and consistent) if FieldsOf
would do the same
Describe alternatives you've considered
The alternative it to write your own simple wrapper provider such as
func InitializeUserConfig(cfg *Config) *UserConfig {
return &cfg.UserConfig
}
Metadata
Assignees
Labels
No labels
Activity