An interface binding instructs goose that a concrete type should be used to satisfy a dependency on an interface type. goose could determine this implicitly, but having an explicit directive makes the provider author's intent clear and allows different concrete types to satisfy different smaller interfaces. Reviewed-by: Tuo Shan <shantuo@google.com>
23 lines
251 B
Go
23 lines
251 B
Go
package main
|
|
|
|
import "fmt"
|
|
|
|
func main() {
|
|
fmt.Println(injectFooer().Foo())
|
|
}
|
|
|
|
type Fooer interface {
|
|
Foo() string
|
|
}
|
|
|
|
type Bar string
|
|
|
|
func (b Bar) Foo() string {
|
|
return string(b)
|
|
}
|
|
|
|
//goose:provide
|
|
func provideBar() Bar {
|
|
return "Hello, World!"
|
|
}
|