https://github.com/golang/tour/blob/master/solutions/readers.go
package main
import "golang.org/x/tour/reader"
type MyReader struct{}
func (r MyReader) Read(b []byte) (int, error) { . //Q1) How is this method getting called?
//Q2) Its no where called in this source code
//Q3) What is the length of b ?
for i := range b { //Q4) Why isn't throwing an infinite loop ?
b[i] = 'A'
}
return len(b), nil
}
func main() {
reader.Validate(MyReader{})
}
蛊毒传说
相关分类