goose: add goose.Value directive

Subsumes previous usage of goose.Optional.

Reviewed-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Tuo Shan <shantuo@google.com>
This commit is contained in:
Ross Light
2018-05-04 12:44:53 -04:00
parent 235a7d8f80
commit 10676a814b
37 changed files with 706 additions and 60 deletions

View File

@@ -50,3 +50,15 @@ type Binding struct{}
func Bind(iface, to interface{}) Binding {
return Binding{}
}
// A ProvidedValue is an expression that is copied to the generated injector.
type ProvidedValue struct{}
// Value binds an expression to provide the type of the expression.
//
// Example:
//
// var MySet = goose.NewSet(goose.Value([]string(nil)))
func Value(interface{}) ProvidedValue {
return ProvidedValue{}
}