552
社区成员
根据你的环境选择对应的版本,这里选择的是windows-x86-64 Archive版
解压到某一文件夹后,将%GOHOME%/bin
添加到环境变量,然后刷新(cmd>: echo %PATH%
)
然后,在终端中输入go version
查看成功与否。成功当有如下输出:
查看GO环境变量的方法:go env
有两个主要的环境变量:
GOHOME
:这个就是安装位置,其中go程序就位于%GOHOME%/bin
中
GOPATH
:
用于指定你的开发工作区(workspace),是存放源代码、测试文件、库静态文件、可执行文件等的位置。
不喜欢默认位置的,可以通过命令更改go env -w GOPATH={your-directory}
。其他变量同理
注意GOPATH的值不能与安装的GOHOME相同。GOHOME中同样有src、pkg、bin等类似工作空间的目录结构,不过其中包含的是go的标准模块,因此最好不要将自己的工作空间和go目录混合,对于以后升级go版本也比较容易。
再设置下软件源,以便后续安装插件
go env -w GO111MODULE=auto go env -w GOPROXY=https://goproxy.cn,direct
安装vscode的go插件
安装go环境的插件
打开vscode的设置<C-S-p>
,然后输入Go:install/update tools
,选择安装即可
成功后应当会提示你:
All tools successfully installed. You are ready to Go. :)
package main import "fmt" func main() { for { var cmd string fmt.Printf("==> Please give your command $ ") fmt.Scanln(&cmd) if cmd == "help" { fmt.Println(" ->hello: give you a greeting from the author") fmt.Println(" ->exit: close this menu") fmt.Println(" ->help: show this help text") } else if cmd == "hello" { fmt.Println("How is everything going?") } else if cmd == "exit" { fmt.Println("exit") break } else { fmt.Println("ERROR: Illeagl Command!\n\tPlease cheak out your input, or get some help by type \"help\"") } } }
运行结果如下
首先在github上创建一个你的仓库
创建ssh-keys
你的电脑和github通过ssh连接需要一个密钥,故首先new一个ssh-key
在里面填入你的ssh公钥即可。
测试网络
ssh -T git@github.com
如果你的网络没问题的话,这里应该能连通。否则后续也没必要进行了
有问题可以参考一些博客,比如:ref1
测试成功应当会提示你:
Hi xxx! You've successfully authenticated, but GitHub does not provide shell access.
远程连接并发布
然后运用git remote
与git push
就可以提交你的内容啦。效果如下图:
学号后三位:200