aboutsummaryrefslogtreecommitdiffstats
path: root/todolist/util.go
diff options
context:
space:
mode:
Diffstat (limited to 'todolist/util.go')
-rw-r--r--todolist/util.go29
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
+}