Homework

Homework — text in your app

YOUR app: a clean display and a correct text check.

Requirements:

  1. Update formatItem with fmt.Sprintf and alignment (%-Ns) so your record looks tidy (title, number, status). Adapt it to your theme (movie, expense, workout…).
  2. Add a text-field check by character count (utf8.RuneCountInString or []rune): the title/name can't be empty and no longer than a limit you pick. Bad input — a message and continue.
  3. Read multi-word text with readLine, not fmt.Scanln — so a title with spaces is read in full.
  4. Prove the gotcha. Add a Lithuanian title (e.g. "Ąžuolų giraitė") and show that len(title) and utf8.RuneCountInString(title) return different numbers. The check must use characters.
  5. gofmt + a working go run.

Extra (for those who want more): add a tags field — the user types "adventure, classic, 2020", and you turn it into a []string with strings.Split + TrimSpace. Show it back with strings.Join.

To submit: the code + a transcript showing: (1) a Lithuanian title read in full, (2) the len vs utf8.RuneCountInString difference for that title, (3) a too-long title being rejected.

Tip. Your app still holds one record. Next lesson is the second milestone: []Item, and your menu learns to hold a whole list — adding and listing many records. And then strings.Builder from step 2 pays off: joining the whole list into one tidy report.