Homework

Homework — your app stops forgetting

The last homework before the finale — YOUR app stops forgetting:

  1. Add JSON tags to your struct fields.
  2. Write saveItems and loadItems for your type (names may differ — what matters is the same shape: returning error, missing file → empty list).
  3. Load on startup, save on quit via q.
  4. Replace Scanln with bufio + readLine — test with a value that contains a space.

Required tests (all three are part of the submission):

  • The restart test: add 2–3 records, quit, run again — the list is back.
  • The first-run test: delete your .json file and run — the app shows an empty list and does NOT crash.
  • The cleanliness test (the lesson 8 habit): gofmt -l . and go vet ./... — both silent.

To submit: the code + a transcript of all three tests + the contents of your .json file.

Tip. Stop and look around: structs, functions, loops, validation, slices, files — every brick is laid. One tool is still missing from your box: the pointer (*Item) — changing a record IN PLACE, without the index trick around copies. Remember the copy gotchas from lessons 3 and 7? The final project gives them their definitive answer — and there, everything you built across 10 lessons assembles into one program.