Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unknown pattern #344

Open
LFernandoC opened this issue Jan 21, 2022 · 5 comments
Open

unknown pattern #344

LFernandoC opened this issue Jan 21, 2022 · 5 comments

Comments

@LFernandoC
Copy link

Struct Providers occurs "unknown pattern",
Case:

package domain_service
...
func ProvidePRDomainService() ProcurementRequestDomainService {
	return ProcurementRequestDomainService{
	}
}
...




package main
...


type ProcurementRequestServiceImpl struct {
	prDomainService domain_service.ProcurementRequestDomainService
}

func InitializePRService() ProcurementRequestServiceImpl {
	panic(wire.Build(domain_service.ProvidePRDomainService(), wire.Struct(new(ProcurementRequestServiceImpl),"*")))
}

...

@LFernandoC
Copy link
Author

with version " github.com/google/wire v0.5.0 "

@LFernandoC
Copy link
Author

ask for help~!!

@ruo-
Copy link

ruo- commented Feb 12, 2022

Is there a import cycle in your project?
occur "unknown pattern" when having a import cycle like:

 import cycle not allowed
 package .../cmd/task
    imports .../sku/intern/impl
    imports .../sku
    imports .../sku/task
    imports .../sku

wire works fine when I fix the import cycle

@jayzhuang
Copy link
Collaborator

panic(wire.Build(domain_service.ProvidePRDomainService(), wire.Struct(new(ProcurementRequestServiceImpl),"*")))
should be
panic(wire.Build(domain_service.ProvidePRDomainService, wire.Struct(new(ProcurementRequestServiceImpl),"*")))

Note domain_service.ProvidePRDomainService should not be invoked, wire.Build expects a provider, not the thing returned by the provider :)

@LFernandoC can you confirm if this fixes things for you?

@ruo-
Copy link

ruo- commented Apr 17, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants