Created
April 15, 2016 10:16
-
-
Save kkabdol/67731042686eb6418a36c0a6b694b3eb to your computer and use it in GitHub Desktop.
go language exercise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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