From 4808994bf548a384f5c4de99b3e5667382bed936 Mon Sep 17 00:00:00 2001 From: Grant Ammons Date: Mon, 2 May 2016 08:49:56 -0400 Subject: Get filtering by projects, contexts working --- todolist/util.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 todolist/util.go (limited to 'todolist/util.go') 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 +} -- cgit v1.3