Documentation
¶
Index ¶
Constants ¶
View Source
const DBLocation = "tasks.json"
Variables ¶
View Source
var ErrCouldntGetTasks = errors.New("couln't get tasks")
View Source
var ErrEmptyJson = errors.New("empty json")
Functions ¶
func DeleteTask ¶
func Initialise ¶
func Initialise()
Types ¶
type ProgressStatus ¶
type ProgressStatus string
const ( NotStarted ProgressStatus = "Not Started" InProgress ProgressStatus = "In Progress" Done ProgressStatus = "Done" )
type Task ¶
type Task struct { Id uint64 `json:"id"` Description string `json:"description"` Status ProgressStatus `json:"status"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` }
func AddTask ¶
AddTask adds a new task with the given description to the task list.
Parameters:
description (string): The description of the new task.
Returns:
*Task: A pointer to the newly created Task. error: An error if the task could not be added, or nil if the task was added successfully.
func GetTasks ¶
func GetTasks(filters ...ProgressStatus) ([]Task, error)
GetTasks retrieves the list of tasks from the database file specified by DBLocation. It reads the file content, unmarshals the JSON data into a slice of Task structs, and returns it. If the file is empty, it returns an ErrEmptyJson error. If there is an error reading the file or unmarshalling the JSON data, it returns the respective error.
Returns:
- []Task: A slice of Task structs representing the tasks.
- error: An error if there is an issue reading the file or unmarshalling the JSON data, or if the file is empty.
Click to show internal directories.
Click to hide internal directories.