Created
November 17, 2018 02:29
-
-
Save fr-xiaoli/38a76b243de4fccff4245bf660d0ab9a to your computer and use it in GitHub Desktop.
A Tour of Go - Methods and interfaces - Exercise: Readers
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" | |
| type MyReader struct{} | |
| func (MyReader) Read(b []byte) (int, error) { | |
| 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