initial push

main
simonkellet 10 months ago
parent 0ba0d27bdf
commit 5e5e0ee732
  1. 3
      go.mod
  2. 78
      main.go
  3. 14
      notes.md
  4. BIN
      todo

@ -0,0 +1,3 @@
module todo-app
go 1.20

@ -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()
}

@ -0,0 +1,14 @@
# TODO APP
## TODO struct
- Title
- Content
- Date (string or Date type?)
## List TODOS
## Add TODO
## Remove TODO

BIN
todo

Binary file not shown.