diff options
| author | Grant Ammons <gammons@gmail.com> | 2016-05-02 08:49:56 -0400 |
|---|---|---|
| committer | Grant Ammons <gammons@gmail.com> | 2016-05-02 08:49:56 -0400 |
| commit | 4808994bf548a384f5c4de99b3e5667382bed936 (patch) | |
| tree | 1a055ffdfeb5b00c64f2b4cf7c89240d1b9b4f9f /todolist/util.go | |
| parent | 471b93141074222bdef537f08b6443e91fa0ea2f (diff) | |
Get filtering by projects, contexts working
Diffstat (limited to 'todolist/util.go')
| -rw-r--r-- | todolist/util.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/todolist/util.go b/todolist/util.go new file mode 100644 index 0000000..4f5371d --- /dev/null +++ b/todolist/util.go @@ -0,0 +1,29 @@ +package todolist + +func AddIfNotThere(arr []string, items []string) []string { + for _, item := range items { + there := false + for _, arrItem := range arr { + if item == arrItem { + there = true + } + } + if !there { + arr = append(arr, item) + } + } + return arr +} + +func AddTodoIfNotThere(arr []Todo, item Todo) []Todo { + there := false + for _, arrItem := range arr { + if item.Id == arrItem.Id { + there = true + } + } + if !there { + arr = append(arr, item) + } + return arr +} |
