You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to build a module system to allow some packages to provide their ProviderSets, along with other package settings.
This means having a structure to be filled by each package, then after processing and composing modules, the idea is to have a global module with an aggregation of the required Wire Providers, Bindings, etc.
In the end, instead of passing a single variable with the provider set, we pass a member from a structure variable to the wire.Build call.
Example:
wire.Build(module.ProviderSet)
instead of
wire.Build(providerSet)
But instead of getting the code generated as expected, I got
internal/wiring/wire.go|32 col 19| unknown pattern
internal/wiring/wire_gen.go|3| running "go": exit status 1
To Reproduce
The following code reproduces the issue
//go:build wireinject
package wiring
import (
"github.com/google/wire"
)
// ClockProvider is a test struct
type ClockProvider struct{}
// This is a Provider function / Constuctor for ClockProvider
func NewProvider() *ClockProvider {
return &ClockProvider{}
}
// This is a mock of a Module Structure that can
// hold a module settings, providers, default values, etc.
type Module struct {
Set wire.ProviderSet
DefaultValues []string
}
// This is a sample module instance
var myModule = Module{
Set: wire.NewSet(NewProvider),
DefaultValues: []string{"Value 1", "Value 2"},
}
// To be generated
func GetClockProvider() (*ClockProvider, error) {
panic(wire.Build(myModule.Set))
}
Expected behavior
The generated code should be the same as the one providing a single variable.
Version
github.com/google/wire v0.5.0
go version go1.19.2 linux/amd64
The text was updated successfully, but these errors were encountered:
diegoortizmatajira
changed the title
Provider set in a field in a structure (For modular buildings)
Calling wire.Build with a provider set from a structure variable (For modular buildings)
Oct 25, 2022
Describe the bug
I am trying to build a module system to allow some packages to provide their ProviderSets, along with other package settings.
This means having a structure to be filled by each package, then after processing and composing modules, the idea is to have a global module with an aggregation of the required Wire Providers, Bindings, etc.
In the end, instead of passing a single variable with the provider set, we pass a member from a structure variable to the
wire.Build
call.Example:
instead of
But instead of getting the code generated as expected, I got
To Reproduce
The following code reproduces the issue
Expected behavior
The generated code should be the same as the one providing a single variable.
Version
The text was updated successfully, but these errors were encountered: