571
社区成员
发帖
与我相关
我的任务
分享


package main
import "fmt"
func main() {
var cmd string
for {
fmt.Print("Please input a command: ")
fmt.Scanln(&cmd)
switch cmd {
case "help":
fmt.Println("This is help command.")
case "quit":
fmt.Println("Bye.")
return
default:
fmt.Println("Wrong command!")
}
}
}
➜ menu_go git:(master) ✗ go run main.go
Please input a command: help
This is help command.
Please input a command: add
Wrong command!
Please input a command: quit
Bye.
作者:532