使用VScode+Go编写menu项目

余生. 2022-03-22 11:54:06

目录

 

一、安装VScode

二、安装Go

 三、gitee创建仓库,克隆到本地

 四、编写menu项目

 author:SA21225256


一、安装VScode

1.1 官网下载对应版本安装:https://code.visualstudio.com/Download

 1.2 下载中文插件(可选)

二、安装Go

2.1 官网下载相应版本安装:https://golang.google.cn/dl/

 2.2 配置环境变量

//用户变量:
GOPATH:%USERPROFILE%\go
Path:%USERPROFILE%\go\bin
系统变量:
GOROOT:D:\Go
Path:D:\Go\bin

在cmd中运行go version查看安装是否成功

2.3 在vscode中下载go插件

 

 三、gitee创建仓库,克隆到本地

3.1 新建menu仓库

3.2 克隆到本地

 

​
git clone https://gitee.com/leikun/menu.git

 四、编写menu项目

4.1 编写代码

package main

import (
	"fmt"
)

func main() {
	var cmd string
	fmt.Print("Menu by lk\n")
	for {
		fmt.Print("******************************\n>")
		fmt.Scanln(&cmd)
		if cmd == "quit" {
			break
		}
		switch cmd {
		case "h":
			fmt.Println("This is helloworld!!!")
		case "help":
			fmt.Println("This is help cmd!")
		case "quit":
			break
		default:
			fmt.Println(cmd + " isn't exist!")
		}
	}
}

4.2 运行调试

PS D:\Go\project\menu> go run .\main.go

 

4.3 推送到gitee仓库

PS D:\Go\project\menu> git status
On branch master
Your branch is up to date with 'origin/master'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        main.go

nothing added to commit but untracked files present (use "git add" to track)
PS D:\Go\project\menu> git add .
PS D:\Go\project\menu> git commit -m "menu"
[master e5eefd5] menu
 1 file changed, 27 insertions(+)
 create mode 100644 main.go      
PS D:\Go\project\menu> git push
info: detecting host provider for 'https://gitee.com/'...
fatal: Custom certificate bundle not found at path: E:/鏉烆垯娆?/Git/mingw64/ssl/certs/ca-bundle.crt
info: detecting host provider for 'https://gitee.com/'...
fatal: Custom certificate bundle not found at path: E:/鏉烆垯娆?/Git/mingw64/ssl/certs/ca-bundle.crt
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 509 bytes | 509.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0        
remote: Powered by GITEE.COM [GNK-6.3]
To https://gitee.com/leikun/menu.git
   468c982..e5eefd5  master -> master

 4.3 查看仓库推送是否成功

 author:SA21225256

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

571

社区成员

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

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