前言

之前用的vscode的自动代码提示,发现太慢了,隔3,4秒才会出提示,所以换为Google推荐的 gopls来代替。

下载过程

方案一

打开 VS Code 的setting, 搜索 go.useLanguageServe, 并勾选上.
默认情况下, 会提示叫你reload,重新打开之后,右下角会自动弹出下载的框框,点击 install即可。
如果下载时间过长,不成功,可以看方案二

方案二

go install github.com/golang/tools/cmd/gopls

方案三

go get golang.org/x/tools/gopls@latest

可以去github上看看文档是怎么说的
github

配置过程

Use the VSCode-Go plugin, with the following configuration:
"go.useLanguageServer": true,
"[go]": {
    "editor.snippetSuggestions": "none",
    "editor.formatOnSave": true,
    "editor.codeActionsOnSave": {
        "source.organizeImports": true,
    }
},
"gopls": {
    "usePlaceholders": true, // add parameter placeholders when completing a function

    // Experimental settings
    "completeUnimported": true, // autocomplete unimported packages
    "watchFileChanges": true,  // watch file changes outside of the editor
    "deepCompletion": true,     // enable deep completion
},
"files.eol": "\n", // formatting only supports LF line endings
setting.jsonCtrl + Shift + PsettingsOpen Settings:JSON