goose: require pointer for first argument to goose.Bind (google/go-cloud#31)

Fixes google/go-cloud#15
This commit is contained in:
Ross Light
2018-05-29 08:45:14 -07:00
parent 7a864edab7
commit e9a61ba66b
6 changed files with 22 additions and 17 deletions

View File

@@ -247,13 +247,13 @@ func ProvideBar() *Bar {
var BarFooer = goose.NewSet(
ProvideBar,
goose.Bind(Fooer(nil), (*Bar)(nil)))
goose.Bind(new(Fooer), new(Bar)))
```
The first argument to `goose.Bind` is a nil value for the interface type and the
second argument is a zero value of the concrete type. An interface binding does
not necessarily need to have a provider in the same set that provides the
concrete type.
The first argument to `goose.Bind` is a pointer to a value of the desired
interface type and the second argument is a zero value of the concrete type. An
interface binding does not necessarily need to have a provider in the same set
that provides the concrete type.
[type identity]: https://golang.org/ref/spec#Type_identity
[return concrete types]: https://github.com/golang/go/wiki/CodeReviewComments#interfaces