wire: update Provider.Out to be a slice of provided types, and keep track of the provided concrete type in ProviderSet.providerMap (google/go-cloud#332)

Update Provider.Out to be a slice of provided types, and keep track
of the provided concrete type in ProviderSet.providerMap, to more
clearly model-named struct providers (which provide both the struct
type and a pointer to the struct type).

Fixes google/go-cloud#325.
This commit is contained in:
Robert van Gent
2018-08-16 15:36:53 -07:00
committed by Ross Light
parent 86725a2b3f
commit e93f33129e
6 changed files with 88 additions and 78 deletions

View File

@@ -22,7 +22,8 @@ import (
func main() {
fb := injectFooBar()
fmt.Println(fb.Foo, fb.Bar)
e := injectEmptyStruct()
fmt.Printf("%d %d %v\n", fb.Foo, fb.Bar, e)
}
type Foo int
@@ -33,6 +34,8 @@ type FooBar struct {
Bar Bar
}
type Empty struct{}
func provideFoo() Foo {
return 41
}

View File

@@ -24,3 +24,8 @@ func injectFooBar() *FooBar {
wire.Build(Set)
return nil
}
func injectEmptyStruct() *Empty {
wire.Build(Empty{})
return nil
}

View File

@@ -1 +1 @@
41 1
41 1 &{}

View File

@@ -16,3 +16,8 @@ func injectFooBar() *FooBar {
}
return fooBar
}
func injectEmptyStruct() *Empty {
empty := &Empty{}
return empty
}