描述
很多时候在windows工作,代码却在linux上面跑,所以有了这记录。
服务端linux使用的是Centos7.5。
客户端windows是用的win7(遗憾win7暂时只用git进行ssh客户端使用)。
其实vscode的测试版或者是正式版都可以实现这一功能的了,不必在意测试版。
工具下载
git官网下载会极度慢
git的github地址速度其实也不快
git淘宝的连接,打开后选择自己要的版本下载吧
vscode地址就不放了。自己百度官网即可
步骤
- 先安装百度回来的文章操作,就应该会遇到这个问题。
- 我的系统是windows7,所以需要安装git,用git的ssh客户端来连接服务器。
- 按照大概步骤:安装vscode→下载Remote Development插件(插件会下载其它所需的其它插件)→再进行vscode配置→最后要重启电脑。
vscode的配置如下:
"remote.SSH.showLoginTerminal": true,
"terminal.integrated.shell.windows": "D:\\Program Files\\Git\\bin\\bash.exe",
"remote.SSH.path": "D:\\Program Files\\Git\\usr\bin\\ssh.exe",
"remote.SSH.remotePlatform": {
"linuxCentos": "linux"
},
"editor.wordwrap":"on",
"editor.minimap.renderCharacters": false,
"editor.minimap.enabled": false,
"terminal.external.osxExec": "iTerm.app",
"go.docsTool": "gogetdoc",
"go.testFlags": ["-v","-count=1"],
"go.buildTags": "",
"go.lintFlags": [],
"go.vetFlags": [],
"go.coverOnSave": false,
"go.useCodeSnippetsOnFunctionSuggest": false,
"go.autocompleteUnimportedPackages": true,
"go.formatOnSave":true,
"window.zoomLevel": 0,
"debug.console.fontSize": 16,
"debug.console.lineHeight": 30,
"git.path": "D:\\Program Files\\Git\\bin\\git.exe",
"workbench.statusBar.visible": true,
"explorer.confirmDelete": false
这里说一下下面这个图:这个图是上面配置的一部分,当时没有把上面的配置全部写上再截图所以下面的图只有一部分。
这样打开配置文件:
插件这个样子:
- 重点来了,需要到linux服务器上,配置一下go语言的代理,国内不可描述原因,所以嘛:
export GOPROXY= https://goproxy.cn
(这个命令在linux系统上敲一下即可。意思就是声明一下GOPROXY
这个全局变量的值是个网址。) - 再查询一下配置情况,命令如下:
[root@Kernel Desktop]# echo $GOPROXY
https://proxy.golang.org,direct
[root@Kernel Desktop]#
- 在linux的用户家目录下面会有一个go文件夹,工具就安装在里面(反正我是能自动补全,自动导入包之类的了,如果还有缺少的go工具,看看vscode,右下角会提示的)。
[root@Kernel bin]# ll
total 21004
-rwxr-xr-x. 1 root root 21505658 Mar 23 23:25 gopls
查看的地方:
安装的路径如下(或者你有go的所有工具直接上传到那里目录也可以。):
go.toolsGopath setting is not set. Using GOPATH /root/go
Installing 7 tools at /root/go/bin in module mode.
[root@Kernel bin]# ls /root/go/bin/
gocode gogetdoc goimports golint go-outline gopkgs gopls
[root@Kernel bin]#