Skip to content

Instantly share code, notes, and snippets.

@fr-xiaoli
Created November 17, 2018 02:29
Show Gist options
  • Select an option

  • Save fr-xiaoli/38a76b243de4fccff4245bf660d0ab9a to your computer and use it in GitHub Desktop.

Select an option

Save fr-xiaoli/38a76b243de4fccff4245bf660d0ab9a to your computer and use it in GitHub Desktop.
A Tour of Go - Methods and interfaces - Exercise: Readers
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