dongmo9996 2019-09-12 13:49
浏览 438

更改导入时,为什么Golang Intellisense在VS Code中运行缓慢?

I have the ms-vscode.go Go extension installed in my VS Code setup and am using the gopls language server. The language server seems to perform well with Intellisense operations except when I am editing imports, at which point there is considerable lag as every edit to the import takes several seconds to update.

For example, the following is a replay of typing in manually import "net/http" letter-by-letter (rather than copy/paste). The clip runs at 20x speed, so it takes about 1.8 minutes from when I stop typing the import statement to when the language server gets to the correct error of "net/http" imported but not used:

enter image description here

Am I doing something wrong?

My go-related settings:

  "go.useLanguageServer": true,
  "go.alternateTools": {
      "go-langserver": "gopls"
  },

Output from gopls reveals that much time is spent in go list:

4.037297s for ...go "list" "-e" "-json" "-compiled=true" "-test=true" "-export=false" "-deps=true" "-find=false" "--" ...

for every change.

  • 写回答

1条回答 默认 最新

  • dsshsta97935 2019-09-17 06:36
    关注

    That might be because:

    You could try and see if the issue persist with saibing/tools, using Go 1.13 in module mode.

    git clone https://github.com/saibing/tools
    cd tools/gopls
    go install
    

    Make sure your ~/go/bin (using the default GOPATH) does show a new gopls executable with a recent timestamp.

    Relaunch VSCode then.


    My gopls settings:

    "gopls": {
        "usePlaceholders": true, // add parameter placeholders when completing a function
        "enhancedHover": true, // experimental to improve quality of hover (will be on by default soon)
    },
    

    But also:

    "[go]": {
        "editor.snippetSuggestions": "none",
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
            "source.organizeImports": true
        },
    },
    "go.lintTool": "golangci-lint",
    "go.useLanguageServer": true,
    "go.languageServerExperimentalFeatures": {
        "format": true,
        "autoComplete": true
    },
    
    评论

报告相同问题?

悬赏问题

  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离