Challenge: Writing to a WIKI Page

This lesson brings you a challenge to solve.

We'll cover the following

Problem statement

The data structure of our program is a struct containing the following fields:

type Page struct {
  Title string
  Body []byte
}

Make a save method on this struct to write a text-file with Title as its name and Body as its content. Make a load function which, given the title string, reads the corresponding text-file. Use *Page as an argument because the structs could be quite large and we don’t want to make copies of them in memory. Use the ioutil functions to read and write from/to a file.

Note: Here’s a link to the detailed documentation of ioutil library.

Try to attempt the challenge below. Good Luck!

Get hands-on with 1200+ tech skills courses.