wire: build provider map incrementally (google/go-cloud#96)

One small breaking change: a provider set can no longer include an
interface binding to a concrete type that is not being provided
(directly or indirectly) by the provider set. I can't imagine a
reasonable use case for the previous behavior, so this likely will
catch more errors

In terms of operation, binding conflict error messages will now give
much more specific line numbers, since they will be reported closer to
where the problem occurred.

Now that provider sets gather this information, it can be exposed in
the package API. gowire now uses this information instead of
trying to build it itself.

Fixes google/go-cloud#29
This commit is contained in:
Ross Light
2018-06-15 15:58:48 -07:00
parent b2d47f8fcc
commit b12449f9e3
5 changed files with 165 additions and 126 deletions

12
wire.go
View File

@@ -48,7 +48,17 @@ type Binding struct{}
//
// Example:
//
// var MySet = wire.NewSet(wire.Bind(new(MyInterface), new(MyStruct)))
// type Fooer interface {
// Foo()
// }
//
// type MyFoo struct{}
//
// func (MyFoo) Foo() {}
//
// var MySet = wire.NewSet(
// MyFoo{},
// wire.Bind(new(Fooer), new(MyFoo)))
func Bind(iface, to interface{}) Binding {
return Binding{}
}