-
Notifications
You must be signed in to change notification settings - Fork 651
Open
Description
Is your feature request related to a problem? Please describe.
I used to write type method instead of a single NewXxx. eg:
// declare NewDog method, which belong to type Animals
type Animals struct{}
func NewAnimals() *Animals {
return &Animals{}
}
type Dog struct{}
func (f *Animals) NewDog() *Dog {
return &Dog{}
}
frustrated when I want to use it as wire provider, I got unknown pattern
error. eg:
// wire.go
//+build wireinject
//go:generate wire
func InitDog() *animals.Dog {
panic(wire.Build(
animals.NewAnimals,
(*animals.Animals).NewDog, // this line will trigger error
))
}
Describe the solution you'd like
I want the above usage could be work. Generated code should looks like:
// wire_gen.go
func InitDog() *animals.Dog {
animalsAnimals := animals.NewAnimals()
dog := (*animals.Animals).NewDog(animalsAnimals)
return dog
}
56KBs, huuhait and anhoder
Metadata
Metadata
Assignees
Labels
No labels