I am trying to use google wire to wire a config field and failing hard at it.
I have the following wire entrypoint
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 trying to make the UserConfig
field in the Config
struct a provider without having to write a simple wrapper initializer just for that.
It is my understanding that wire.FieldsOf
is supposed to do exactly this however it does not seem to work (keep geting no provider found for *Config
). My guess is it only provides a UserConfig
and not a *UserConfig
.
Without changing the UserConfig
field to a pointer or writing a initializer wrapper that takes a config and returns a *UserConfig
, is there any way to do this in wire?