Skip to content
This repository was archived by the owner on Aug 25, 2025. It is now read-only.
This repository was archived by the owner on Aug 25, 2025. It is now read-only.

cycle for int: int (provideFunc) -> int generate failed #291

Description

@wensenz

You can use go bug to have a cool, automatically filled out bug template, or
fill 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions