golang-exercises/golangr/goroutines/main.go

48 lines
638 B
Go
Raw Normal View History

2024-02-26 11:59:46 +01:00
package main
import (
"fmt"
"os"
"strconv"
"time"
2024-02-26 11:59:46 +01:00
)
var check bool = false
var choice string
var err error
2024-03-20 20:59:48 +01:00
func mainStatus() {
clear()
fmt.Printf("[1] Basic concurrency\n")
fmt.Printf("[2] Channels\n")
fmt.Printf("[3] Exit\n")
fmt.Printf("\rChoose your function: ")
}
func main() {
var numChoice int
for {
2024-03-20 20:59:48 +01:00
mainStatus()
strChoice := scanLine()
numChoice, err = strconv.Atoi(strChoice)
catchErr(err)
switch numChoice {
case 1:
fun1()
os.Exit(0)
case 2:
fun2()
os.Exit(0)
2024-03-20 20:59:48 +01:00
case 3:
os.Exit(0)
default:
fmt.Printf("Choose an actual function, please\n")
time.Sleep(time.Second)
}
}
2024-02-26 11:59:46 +01:00
}