VSCode创建版本库,配置Go环境,编写menu程序

我学不完了 2022-03-19 13:18:11

创建版本库并clone到本地

​ 先在GitHub上面Create a new repository。

img

​ 然后把项目clone到本地。

PS F:\CodeWorkStations\GitStation\menu> git clone https://github.com/PrearWing/menu.git

Cloning into 'menu'...
warning: You appear to have cloned an empty repository.

​ 打开VSCode,打开刚才clone的项目。因为在VSCode中配置了使用Git Bash,现在可以看到是成功创建了版本库并且顺利打开了。

img

配置Go语言环境

​ 进入Extensions后直接搜索go进行安装。

img

​ 新建go文件,看是否配置完成。结果发现还有东西没安装,继续安装。

img

​ 但是老是报错。这里参考了VSCode 安装 Go 插件失败解决方案。使用如下命令可解决:

go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct

img

编写menu第一版简单程序

​ 新建go文件,编写代码。

img

​ 运行查看结果:

img

提交到远程仓库

24173@DESKTOP-22U5NA6 MINGW64 /f/CodeWorkStations/GitStation/menu (main)
$ git add *

24173@DESKTOP-22U5NA6 MINGW64 /f/CodeWorkStations/GitStation/menu (main)
$ git commit -m "Hello World"
[main (root-commit) d18dfc9] Hello World
 1 file changed, 7 insertions(+)        
 create mode 100644 main/main.go        

24173@DESKTOP-22U5NA6 MINGW64 /f/CodeWorkStations/GitStation/menu (main)
$ git push origin main 
fatal: unable to access 'https://github.com/PrearWing/menu.git/': OpenSSL SSL_connect: Connection was reset in connection to github.com:443 

​ 运行到这里报错,查阅资料发现是代理的问题。参考解决github无法连接错误 OpenSSL SSL_connect: Connection was reset in connection to github.com:443 ,然后接着尝试。

24173@DESKTOP-22U5NA6 MINGW64 /f/CodeWorkStations/GitStation/menu (main)
$ git push origin main 
warning: ----------------- SECURITY WARNING ----------------
warning: | TLS certificate verification has been disabled! |
warning: ---------------------------------------------------
warning: HTTPS connections may not be secure. See https://aka.ms/gcm/tlsverify for more information.
warning: ----------------- SECURITY WARNING ----------------
warning: | TLS certificate verification has been disabled! |
warning: ---------------------------------------------------
warning: HTTPS connections may not be secure. See https://aka.ms/gcm/tlsverify for more information.
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (4/4), 315 bytes | 315.00 KiB/s, done.
Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/PrearWing/menu.git
 * [new branch]      main -> main

​ 在这个过程中,它会弹出提示框让你选择登录GitHub账户的方式,按照提示操作即可。

img

​ 大功告成。

作者:465

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

571

社区成员

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

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