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

[Question] Is there a guice for build a singleton object? #370

Open
Moln opened this issue Aug 21, 2022 · 0 comments
Open

[Question] Is there a guice for build a singleton object? #370

Moln opened this issue Aug 21, 2022 · 0 comments

Comments

@Moln
Copy link

Moln commented Aug 21, 2022

I had read the guide, but not found build the singleton example.

// wire.go
func InitializeFoo() *Foo {
    panic(wire.Build(NewFoo))
}

// wire_gen.go
func InitializeFoo() *Foo {
    return NewFoo()
}

// main.go
func main() {
  foo1 := InitializeFoo()
  foo2 := InitializeFoo()
  foo1 != foo2 //  How to build the singleton object?
}
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

1 participant