Answer the question
In order to leave comments, you need to log in
Why does default work all the time?
When specifying the correct options, default still works. Why?
package _cmd
import (
"fmt"
"os"
)
func BootCmd() {
if len(os.Args) > 1 {
for index, element := range os.Args {
if index == 1 && element == "-menu" {
menuMaster()
break
}
if index > 2 {
return
}
}
} else {
return
}
}
func menuMaster() {
fmt.Println("--- Servus Menu ---")
fmt.Println("0. Exit")
fmt.Println("1. Continue booting")
fmt.Println("2. Create superuser")
var selected string
scanner(selected)
switch selected {
case "0": os.Exit(1)
case "1": return
case "2": fmt.Println("окей")
default:
fmt.Println("Wrong selection. Try again.")
menuMaster()
}
return
}
func scanner(writeTo string){
_, err := fmt.Fscan(os.Stdin, &writeTo)
if err != nil {
panic(err)
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question