Skip to content

Commit

Permalink
little edit
Browse files Browse the repository at this point in the history
  • Loading branch information
quii committed Mar 16, 2018
1 parent 25300a5 commit 14f0d92
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions di-and-interfaces/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ The test will not compile

## Write the minimal amount of code for the test to run and check the failing test output

_Listen to the compiler_ and fix the problem.

```go
func Greet(writer *bytes.Buffer, name string) {
fmt.Printf("Hello, %s", name)
Expand Down Expand Up @@ -127,9 +129,9 @@ func main() {

`./di.go:14:7: cannot use os.Stdout (type *os.File) as type *bytes.Buffer in argument to Greet`

As discussed earlier `fmt.Fprintf` allows you to pass in an `io.Writer` which we know both `os.Stdout` and `bytes.Buffer` both implement.
As discussed earlier `fmt.Fprintf` allows you to pass in an `io.Writer` which we know both `os.Stdout` and `bytes.Buffer` implement.

If we change our code to use the more general purpose interface we can then use it in both tests and in our application
If we change our code to use the more general purpose interface we can then use it in both tests and in our application.

```go
package main
Expand Down

0 comments on commit 14f0d92

Please sign in to comment.