diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..3622b60 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module todo-app + +go 1.20 diff --git a/main.go b/main.go new file mode 100644 index 0000000..13b0b8d --- /dev/null +++ b/main.go @@ -0,0 +1,78 @@ +package main + +import ( + "fmt" +) + +type Todo struct { + Title string + Content string +} + +type Todos struct { + Items []Todo +} + +func (todo *Todos) AddTodo(newTodo Todo) { + todo.Items = append(todo.Items, newTodo) +} + +func (todo *Todos) RemoveTodo(index int) { + //remove todo via index + todo.Items = append(todo.Items[:index], todo.Items[index+1:]...) +} + +func (todo *Todos) ListTodosFull() { + //List all the contents + if len(todo.Items) == 0 { + fmt.Printf("empty\n") + } + for k, v := range todo.Items { + fmt.Printf("%d:%s\n", k, v) + } +} + +func ListTodosSmall() { + fmt.Println("ListTodosSmall func. not implemented") + //List all the contents +} +func main() { + fmt.Println("TODO APP") + + list := Todos{} + //todos := []Todo{} + //list := Todos{todos} + fmt.Println("Empty list: ") + list.ListTodosFull() + + fmt.Println("Adding entries...") + items := []Todo{ + { + Title: "test", + Content: "Here is some content", + }, + { + Title: "test1", + Content: "Here is some more content", + }, + { + Title: "test2", + Content: "Here is even MORE content", + }, + } + + //Add the items for testing + for item := range items { + list.AddTodo(items[item]) + } + + fmt.Println("Listing...") + list.ListTodosFull() + fmt.Println("Listing again...") + list.ListTodosFull() + + fmt.Println("Removing item2 via index 1") + list.RemoveTodo(1) + fmt.Println("Listing again...") + list.ListTodosFull() +} diff --git a/notes.md b/notes.md new file mode 100644 index 0000000..5edffd5 --- /dev/null +++ b/notes.md @@ -0,0 +1,14 @@ +# TODO APP + +## TODO struct +- Title +- Content +- Date (string or Date type?) + +## List TODOS + +## Add TODO + +## Remove TODO + + diff --git a/todo b/todo new file mode 100755 index 0000000..a84f5f4 Binary files /dev/null and b/todo differ