先远程连接 linux
- 没有远程连接 linux的同学可以参考我的这篇博文
vscode远程连接linux服务器
先用vscode 连接远程linux服务器
开始安装go插件
- 安装 go 插件 ,点击 install in SSH: 服务器上
- 重启vscode, 随便写一个go 程序,vscode 右下角会有下面的弹出框, 点击
Install All
安装 所有的 gotools 插件 (可能需要翻墙),
如果安装失败 可以试试把我安装编译好的程序放到GOPATH/bin 目录下(或者 PATH 目录下,能让vscode 找到它), 文件地址 https://github.com/wanmei002/diary/tree/master/go_ext,同时 在 settings.json 里加一行 go.toolsGoPath 文件地址写成 编译好的文件存放的目录(如果文件放在了 GOPATH/bin 目录下就不需要这一步)
- 此时 IDE 环境基本配置完成了
番外篇
goreturns 不支持 gomodule, 设置 settings.json: “go.formatTool”: “goimports”
下面是我的 settings.json :
{
"go.goroot": "",
"go.gopath": "",
"go.inferGopath": true,
"go.autocompleteUnimportedPackages": true,
"go.gocodePackageLookupMode": "go",
"go.gotoSymbol.includeImports": true,
"go.useCodeSnippetsOnFunctionSuggest": true,
"go.useCodeSnippetsOnFunctionSuggestWithoutType": true,
"go.docsTool": "gogetdoc",
"remote.SSH.showLoginTerminal": true,
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\wsl.exe",
"go.formatTool": "goimports",
"go.useLanguageServer": true,
"remote.SSH.remotePlatform": {
"v_zzzzhou": "linux",
"devcloud": "linux",
"wz": "linux"
},
"terminal.integrated.shell.linux": "/bin/bash",
}