Theory

Literals, the dot, and copies

A few struct details that quickly become daily routine.

Literal forms. With field names (recommended — order does not matter, omitted fields get zero values) or without (all fields, exactly in order):

a := Item{Title: "Dune", Pages: 412}       // Read omitted → false
b := Item{"Dune", 412, true}               // no names — all fields, in order
var c Item                                  // zero struct: "", 0, false

Notice: zero values work inside structs toovar c Item is a safe, empty record (lesson 2's rule applies to every field).

Changing through the dot. a.Pages = 500 — a field is changed in place, like a plain variable.

Copies. A struct is a value, so assignment and passing to a function make a full copy:

a := Item{Title: "Dune", Pages: 412}
b := a          // b is a full COPY
b.Pages = 500
fmt.Println(a.Pages) // 412 — the original did not change

Gotcha. This is lesson 3's copy trap, now with the whole record: set it.Read = true inside markRead(it Item) and you changed only the copy — the original stays false. For now the fix is the same — the function returns the changed record (it = markRead(it)). In lesson 11 the *Item pointer will let you change the original directly — which is exactly why the final project requires it.