I have created a new type TaskList which is a struct containing a slice of Task structs. All the previous methods which were operating on the global Tasks slice are now methods on the TaskList struct and operate on the Tasks field inside the TaskList structure. In fact, the main.go file does not contain any global variables anymore: the filename is passed directly as an argument to the loadTasksFromFile and saveTasksToFile methods and a new TaskList instance is created directly in the main function.
I have created a new type
TaskList
which is a struct containing a slice ofTask
structs. All the previous methods which were operating on the globalTasks
slice are now methods on theTaskList
struct and operate on theTasks
field inside theTaskList
structure. In fact, themain.go
file does not contain any global variables anymore: the filename is passed directly as an argument to theloadTasksFromFile
andsaveTasksToFile
methods and a newTaskList
instance is created directly in themain
function.Resolves #23