adding common interfaces koan

This commit is contained in:
Steven Degutis
2012-03-26 18:15:06 -05:00
parent 52956ab14e
commit b739e5f329
2 changed files with 33 additions and 0 deletions

View File

@@ -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
}
}

View File

@@ -32,6 +32,7 @@ func TestKoans(t *testing.T) {
aboutVariadicFunctions()
aboutFiles()
aboutInterfaces()
aboutCommonInterfaces()
aboutMaps()
aboutPointers()
aboutStructs()