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:
Robert van Gent
2018-08-14 14:55:28 -07:00
committed by Ross Light
parent eedae3d8d0
commit cd32a686b1
20 changed files with 296 additions and 3 deletions

View File

@@ -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),