/
main.go
54 lines (46 loc) · 913 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
import "fmt"
// Task represents a single to-do item
type Task struct {
ID int
Title string
}
var tasks []Task
var idCounter int
func main() {
executeVanilla := false
operationType := func() string {
if executeVanilla {
return "Vanilla"
}
return "Instrumented"
}()
for {
fmt.Printf("\nTo-Do App (%s version)\n", operationType)
fmt.Println("-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-")
displayMenu()
choice := getUserChoice()
if executeVanilla {
// Vanilla
executeChoice(choice)
} else {
// Instrumented
executeChoiceInstrumented(choice)
}
}
}
func displayMenu() {
fmt.Println("1. Add Task")
fmt.Println("2. List Tasks")
fmt.Println("3. Exit")
fmt.Print("Enter your choice: ")
}
func getUserChoice() int {
var choice int
_, err := fmt.Scan(&choice)
if err != nil {
fmt.Println("Invalid input. Please enter a number.")
return 0
}
return choice
}