From b739e5f329d5d7ed3bf59ddff5328643687c10d2 Mon Sep 17 00:00:00 2001 From: Steven Degutis Date: Mon, 26 Mar 2012 18:15:06 -0500 Subject: [PATCH] adding common interfaces koan --- about_common_interfaces.go | 32 ++++++++++++++++++++++++++++++++ setup_koans_test.go | 1 + 2 files changed, 33 insertions(+) create mode 100644 about_common_interfaces.go diff --git a/about_common_interfaces.go b/about_common_interfaces.go new file mode 100644 index 0000000..80eb6b6 --- /dev/null +++ b/about_common_interfaces.go @@ -0,0 +1,32 @@ +package go_koans + +import "bytes" + +func aboutCommonInterfaces() { + { + in := new(bytes.Buffer) + in.WriteString("hello world") + + out := new(bytes.Buffer) + + /* + Your code goes here. + Hint, use these resources: + + $ godoc -http=:8080 + $ open http://localhost:8080/pkg/io/ + $ open http://localhost:8080/pkg/bytes/ + */ + + assert(out.String() == "hello world") // get data from the io.Reader to the io.Writer + } + + { + in := new(bytes.Buffer) + in.WriteString("hello world") + + out := new(bytes.Buffer) + + assert(out.String() == "hello") // duplicate only a portion of the io.Reader + } +} diff --git a/setup_koans_test.go b/setup_koans_test.go index 8ce24b2..461aa2d 100644 --- a/setup_koans_test.go +++ b/setup_koans_test.go @@ -32,6 +32,7 @@ func TestKoans(t *testing.T) { aboutVariadicFunctions() aboutFiles() aboutInterfaces() + aboutCommonInterfaces() aboutMaps() aboutPointers() aboutStructs()