Commit ae636a1

mo khan <mo.khan@gmail.com>
2019-11-23 20:45:09
learn about di
1 parent 0a64fd9
di_test.go
@@ -0,0 +1,18 @@
+package main
+
+import (
+	"bytes"
+	"testing"
+)
+
+func TestGreet(t *testing.T) {
+	buffer := bytes.Buffer{}
+	Greet(&buffer, "mo")
+
+	got := buffer.String()
+	want := "Hello, mo"
+
+	if got != want {
+		t.Errorf("got %q want %q", got, want)
+	}
+}
greet.go
@@ -0,0 +1,15 @@
+package main
+
+import (
+	"fmt"
+	"io"
+	"os"
+)
+
+func Greet(writer io.Writer, name string) {
+	fmt.Fprintf(writer, "Hello, %s", name)
+}
+
+func main() {
+	Greet(os.Stdout, "Elodie")
+}
hello.go
@@ -1,6 +1,6 @@
 package main
 
-import "fmt"
+//import "fmt"
 
 const spanish = "Spanish"
 const french = "French"
@@ -28,6 +28,6 @@ func greetingPrefix(language string) (prefix string) {
 	return
 }
 
-func main() {
-	fmt.Println(Hello("world", ""))
-}
+//func main() {
+//fmt.Println(Hello("world", ""))
+//}