571
社区成员
发帖
与我相关
我的任务
分享目录
官网下载安装即可 : https://golang.org/dl/
配置系统环境变量:
GOROOT
GOPATH
export GOPROXY=https://goproxy.io(尤其注意配置代理,不然后续Vscode go工具的安装会失败)
安装完成后,在cmd下查看是否成功




先使用go mod init go-test初始化目录

创建menu.go文件,写代码。(这时会提示你安装一些go工具,只要前面配置好代理,直接全部安装即可)

package main
import (
"fmt"
)
func main() {
var command string
fmt.Print("Menu by lk\n")
for {
fmt.Print("*********Please enter a command!***********\n>")
fmt.Scanln(&command)
if command == "quit" {
break
}
switch command {
case "h":
fmt.Println("This is helloworld!!!")
case "help":
fmt.Println("This is help s!")
case "quit":
break
default:
fmt.Println(command + " isn't exist!")
}
}
}
测试运行代码