code updates #1

Open
opened 2024-03-29 21:31:08 +01:00 by urko · 0 comments

Here you could do like

func (r *taskService) Show(key int) (string, error) {
	if task, !found := r.tasks[key]; !found {
		return "", fmt.Errorf("task not found")
	} else {
    	return task, nil
    }
}

Then here you only have to check for error

Rest is fine, just some coding style preferences.

[Here](https://gitea.urkob.com/longinos/toDoList/src/commit/c0e345d16909ed04861521a334cab3e0e3995cd5/internal/services/tasks.go#L26-L31) you could do like ```go func (r *taskService) Show(key int) (string, error) { if task, !found := r.tasks[key]; !found { return "", fmt.Errorf("task not found") } else { return task, nil } } ``` Then [here](https://gitea.urkob.com/longinos/toDoList/src/commit/c0e345d16909ed04861521a334cab3e0e3995cd5/main.go#L78-L82) you only have to check for error Rest is fine, just some coding style preferences.
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: longinos/toDoList#1
No description provided.