golang / tour

[mirror] A Tour of Go
BSD 3-Clause "New" or "Revised" License
1.55k stars 520 forks source link

tour: provide answers to exercises #1426

Open laurencefass opened 1 year ago

laurencefass commented 1 year ago

Context: https://go.dev/tour/methods/22

Hi rather than make exercises a school-like academic engagement to prove understanding please can you provide the answers to exercises available (with a single click)? This would be useful to professional developers new to Go limited in time for answering questions.

Thanks

mcepl commented 3 months ago

Created this:

package main

import (
    "golang.org/x/tour/reader"
)

type MyReader struct{}

func (MyReader) Read(b []byte) (n int, err error) {
    for i := 0; i < n; i++ {
        b = append(b, "a"[0])
    }
    return n, nil
}

func main() {
    reader.Validate(MyReader{})
}

which is most likely wrong, but I cannot find a way how to see what I did wrong.