Created
December 3, 2018 04:34
-
-
Save bilsalak/888e46ac446e0b3d0e524aa0949d2e0a to your computer and use it in GitHub Desktop.
A Tour of Go - 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
// Implement a Reader type that emits an infinite stream of the ASCII character 'A'. | |
package main | |
import ( | |
"golang.org/x/tour/reader" | |
) | |
type MyReader struct{} | |
// TODO: Add a Read([]byte) (int, error) method to MyReader. | |
func (r MyReader) Read(p []byte) (int, error) { | |
p[0] = 'A' | |
return 1, nil | |
} | |
func main() { | |
reader.Validate(MyReader{}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment