Replies: 1 comment
-
Wire's dependency graph is keyed by Go type. The error message is indicating that in order to provide an The common solution for this is to define a second named type to break the cycle. See this FAQ for an example. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
You can use
go bug
to have a cool, automatically filled out bug template, orfill out the template below.
Describe the bug
my test1.go
package main
type Test1 interface {
Func(x int) int
}
type myTest string
func (m *myTest) Func(x int) int {
return x
}
func provideMyTest() *myTest {
m := new(myTest)
*m = "hello wire!"
return m
}
func provideFunc(t Test1, x int) int {
val := t.Func(x)
return val
//return fmt.Sprintf("hello, %v", val)
}
my inject_test1.go
//+build wireinject
package main
import "github.com/google/wire"
var Set1 = wire.NewSet(provideMyTest,
wire.Bind(new(Test1), new(*myTest)),
provideFunc)
func InitFunc(x int) int {
wire.Build(Set1)
return 0
//return "22"
}
error:
wire
wire: inject_test1.go:7:12: cycle for int:
int (demo/test.provideFunc) ->
int
wire: demo/test: generate failed
wire: at least one generate failure
why?
Beta Was this translation helpful? Give feedback.
All reactions