VSCode 远程 Linux 的 Golang 开发环境搭建(内网)(备忘)

准备材料

《VSCode 远程 Linux 的 Golang 开发环境搭建(备忘)》 Windows 机(外网)都通顺后

准备以下材料:

在这里插入图片描述

其他须知

  • go env
    • 可以获取 go GOPATH ,比如 /home/fananchong/go ,windows 也一样
材料 目录位置 说明
extensions Windows 机 %USERPROFILE%.vscode\extensions VSCode 插件安装都在这个目录下
linux.go.bin Linux 机 /home/fananchong/go/bin/ ms-vscode.go 安装好后,提示安装的 go 工具在这个目录下
win.go.bin Windows 机 C:\Users\fananchong\go\bin ms-vscode.go 安装好后,提示安装的 go 工具在这个目录下
.vscode-server.zip Linux 机 /home/fananchong/ Remote-SSH 服务器端程序、其他 VScode linux 插件等等
go.1.14.linux-amd64.tar.gz 官网或其他渠道下载 golang
go.1.14.windows-amd64.msi 官网或其他渠道下载 golang
Microsoft VS Code.zip C:\Users\fananchong\AppData\Local\Programs Windows 机 VSCode 安装目录

把以上准备材料,拷贝至内网

内网部署

  1. 使用 go.1.14.linux-amd64.tar.gz 、 go.1.14.windows-amd64.msi 默认方式在 linux 机 、 windows 机上安装 golang
  2. extensions linux.go.bin win.go.bin .vscode-server.zip Microsoft VS Code.zip 分别解压放到上面介绍的路径下

需要注意:

  1. linux.go.bin 解压到 linux 机 /home/fananchong/go/bin/ 目录后,注意 chmod +x
  2. linux 机配置稍微好些,不然代码自动补全之类的会延迟很慢
  3. 一般会提示 git 版本 1.8.x 太低,内网 linux 机上一般你也无法更新 git 版本,直接点击永久忽略

以上

自动补全延迟太大

linux 机配置太低,会导致 CPU 忙,可以使用下列配置,禁用些功能,加快速度

"go.useLanguageServer": true,
"[go]": {
    "editor.formatOnSave": true,
    "editor.codeActionsOnSave": {
        "source.organizeImports": true,
    },
    // Optional: Disable snippets, as they conflict with completion ranking.
    "editor.snippetSuggestions": "none",
},
"[go.mod]": {
    "editor.formatOnSave": true,
    "editor.codeActionsOnSave": {
        "source.organizeImports": true,
    },
},
"gopls": {
     // Add parameter placeholders when completing a function.
    "usePlaceholders": true,

    // If true, enable additional analyses with staticcheck.
    // Warning: This will significantly increase memory usage.
    "staticcheck": false
},
"go.gocodeAutoBuild": true

猜你喜欢

转载自blog.csdn.net/u013272009/article/details/104823840