goose: remove optional directive
This introduces some short-term pain in practice, but I aim to fix that with the goose.Value directive. Reviewed-by: Tuo Shan <shantuo@google.com>
This commit is contained in:
19
README.md
19
README.md
@@ -245,22 +245,6 @@ 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
|
||||
|
||||
### Optional Inputs
|
||||
|
||||
A provider input can be marked optional using `goose:optional`:
|
||||
|
||||
```go
|
||||
//goose:provide Bar
|
||||
//goose:optional foo
|
||||
|
||||
func provideBar(foo Foo) Bar {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
If used as part of an injector that does not bring in the `Foo` dependency, then
|
||||
the injector will pass the provider the zero value as the `foo` argument.
|
||||
|
||||
### Struct Providers
|
||||
|
||||
Structs can also be marked as providers. Instead of calling a function, an
|
||||
@@ -308,9 +292,6 @@ func injectFooBar() FooBar {
|
||||
|
||||
And similarly if the injector needed a `*FooBar`.
|
||||
|
||||
Like function providers, you can mark dependencies of a struct provider optional
|
||||
by using the `goose:optional` directive with the field names.
|
||||
|
||||
### Cleanup functions
|
||||
|
||||
If a provider creates a value that needs to be cleaned up (e.g. closing a file),
|
||||
|
||||
Reference in New Issue
Block a user