โ
Task Manager LabLAB
Task Manager Lab
In this lab you will build a simple in-memory task manager using structs and pointer receiver methods.
Data types
Methods to implement
(m *TaskManager) Add(title string, priority int)
- Create a new Task with
IDset tom.nextID, then incrementm.nextID - Append the task to
m.tasks
(m *TaskManager) Complete(id int)
- Find the task with the given ID and set its
Donefield totrue
(m *TaskManager) Remove(id int)
- Remove the task with the given ID from
m.tasks
(m *TaskManager) Pending() []Task
- Return a slice containing only tasks where
Done == false
In main
- Create a
TaskManagerwithnextIDstarting at 1 - Add three tasks:
"Write tests"(priority 1),"Fix bug"(priority 2),"Deploy"(priority 3) - Complete the task with ID 1
- Remove the task with ID 2
- Print each pending task's Title
Expected output
โ Enter (Mac) ยท Ctrl+Enter (Win/Linux)
โ Enter (Mac) ยท Ctrl+Enter (Win/Linux)