wire: Add wire.InterfaceValue, required instead of wire.Value if the value is an interface value (google/go-cloud#322)
* Add wire.InterfaceValue, required instead of wire.Value if the value is an interface value. * Update guestbook sample to use InterfaceValue where appropriate. * Remove unnecessary ok := true * Addressing comments from code review.
This commit is contained in:
committed by
Ross Light
parent
eedae3d8d0
commit
cd32a686b1
@@ -317,6 +317,14 @@ package; references to variables will be evaluated during the injector
|
||||
package's initialization. Wire will emit an error if the expression calls
|
||||
any functions or receives from any channels.
|
||||
|
||||
For interface values, use `InterfaceValue`:
|
||||
|
||||
```go
|
||||
func injectReader() io.Reader {
|
||||
wire.Build(wire.InterfaceValue(new(io.Reader), os.Stdin))
|
||||
return Foo{}
|
||||
}
|
||||
```
|
||||
### 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