Lab:VS Code配置Go语言开发环境,编写menu第一版简单程序

m0_51146068 2023-03-20 12:45:32

 

本地安装go 配置vs

 

 创建main.go文件,编写代码,并运行

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

...全文
23 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

571

社区成员

发帖
与我相关
我的任务
社区描述
软件工程教学新范式,强化专项技能训练+基于项目的学习PBL。Git仓库:https://gitee.com/mengning997/se
软件工程 高校
社区管理员
  • 码农孟宁
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧