simonkellet 9 months ago
parent 694b4c2cdb
commit 5ab7eb6e0b
  1. 43
      main.go
  2. BIN
      todo
  3. 2
      todo.go

@ -7,7 +7,7 @@ import (
)
func PrintMenu() {
fmt.Printf("### TODO APP ###\n")
fmt.Printf("\n\n### TODO APP ###\n")
fmt.Printf("1: List Todo\n")
fmt.Printf("2: Add Todo\n")
fmt.Printf("3: Remove Todo (via index)\n")
@ -51,7 +51,7 @@ func main() {
fmt.Printf("Which TODO to remove?\n> ")
if _, err := fmt.Scanf("%d", &index); err != nil {
fmt.Printf("Invalid input\n> ")
fmt.Printf("Which TODO to remove?\n> ")
}
if err := list.RemoveTodo(index); err != nil {
@ -65,43 +65,4 @@ func main() {
PrintMenu()
}
}
/*
list := Todos{}
//todos := []Todo{}
//list := Todos{todos}
fmt.Println("Empty list: ")
list.ListTodo()
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.ListTodo()
fmt.Println("Listing again...")
list.ListTodo()
fmt.Println("Removing item2 via index 1")
list.RemoveTodo(1)
fmt.Println("Listing again...")
list.ListTodo()
*/
}

BIN
todo

Binary file not shown.

@ -25,7 +25,7 @@ func (todo *Todos) RemoveTodo(index int) (err error) {
}
if index > len(todo.Items) {
return errors.New("[ERR] Index out of bounds")
return errors.New("[ERR] Index out of bounds\n")
}
todo.Items = append(todo.Items[:index], todo.Items[index+1:]...)