Skip to content

Instantly share code, notes, and snippets.

@bilsalak
Created December 3, 2018 04:34
Show Gist options
  • Save bilsalak/888e46ac446e0b3d0e524aa0949d2e0a to your computer and use it in GitHub Desktop.
Save bilsalak/888e46ac446e0b3d0e524aa0949d2e0a to your computer and use it in GitHub Desktop.
A Tour of Go - Exercise: Readers
// 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