-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
95 lines (90 loc) · 2 KB
/
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package main
/* ---------------------------------
an application for learning Go.
by Elucian Moise on Sage-Code
--------------------------------- */
import (
"fmt"
array "golang/array"
demo "golang/demo"
)
/* show on console the options to
explain what the app does */
func print_menu() {
fmt.Println("---------------------- ")
fmt.Println(" MAIN ")
fmt.Println("---------------------- ")
fmt.Println("Q = quit")
fmt.Println("H = Hello World")
fmt.Println("F = For loop")
fmt.Println("L = Ladder")
fmt.Println("E = Infinite loop")
fmt.Println("V = Value switch")
fmt.Println("G = Cond switch")
fmt.Println("C = Local scope")
fmt.Println("I = Array Init")
fmt.Println("S = Array Slice")
fmt.Println("I = Interpolation")
fmt.Println("F = For while")
fmt.Println("X = Exit")
fmt.Println("--------------------- ")
fmt.Println("SUBMENU: 0,1,2,3,4")
// next menu in in second.go
}
/* clear the screen */
func clear() {
fmt.Print("\033[H\033[2J")
}
/* entry point, start the main loop */
func main() {
option := "_"
fmt.Println("Run demo: ")
print_menu()
// the actual loop (cycle)
for option != "Q" {
fmt.Print(">>")
fmt.Scanf("%s", &option)
// fmt.Print(option)
if option == "Q" {
break
} else if option == "0" {
clear()
} else if option == "H" {
demo.Hello()
} else if option == "L" {
demo.Ladder()
} else if option == "E" {
demo.Infinite_loop()
} else if option == "V" {
demo.Value_switch()
} else if option == "G" {
demo.Cond_switch()
} else if option == "C" {
demo.Local_scope()
} else if option == "S" {
array.Slice()
} else if option == "I" {
array.Init()
} else if option == "F" {
demo.For_loop()
} else if option == "X" {
demo.DemoExit();
} else if option == "1" {
clear()
first()
} else if option == "2" {
clear()
second()
} else if option == "3" {
clear()
third()
} else if option == "4" {
clear()
forth()
} else {
clear()
print_menu()
}
option = "_"
} //for
}