Skip to content

Instantly share code, notes, and snippets.

@kkabdol
Created April 15, 2016 10:16
Show Gist options
  • Save kkabdol/67731042686eb6418a36c0a6b694b3eb to your computer and use it in GitHub Desktop.
Save kkabdol/67731042686eb6418a36c0a6b694b3eb to your computer and use it in GitHub Desktop.
go language exercise
package main
import (
"golang.org/x/tour/reader"
"io"
)
type MyReader struct{}
// TODO: Add a Read([]byte) (int, error) method to MyReader.
func (m MyReader) Read(b []byte) (int, error) {
if len(b) == 0 {
return 0, io.EOF
} else {
for i := 0; i < len(b); i ++ {
b[i] = 'A'
}
return len(b), nil
}
}
func main() {
reader.Validate(MyReader{})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment