ReadAt method

Report a typo

In this task, you will try another useful method: ReadAt() from io package. ReadAt() implements the io.ReaderAt interface.

Take a look at the ReadAt() method definition below, where off represents the offset (which you may recall from the Seek() method):

func (r *Reader) ReadAt(b []byte, off int64) (n int, err error)

Please, write the missing code so that the program will output the string: "money".

Write a program in Go
package main

import (
"fmt"
"log"
"strings"
)

const quote = "Knowledge is better than money"

// nolint: gomnd // DO NOT delete this comment!
func main() {
reader := strings.NewReader(quote)

// Write the missing code below so that the program will output "money"
buf := make([]byte, ??)
_, err := reader.ReadAt(??, ??)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(buf))
}
___

Create a free account to access the full topic