Go intelisense和autocomplete在vscode中不工作

mhd8tkvw  于 5个月前  发布在  Go
关注(0)|答案(2)|浏览(73)

我已经在mac上安装了go,在vscode中我安装了官方的go扩展,但是自动完成不工作
当我打开一个go文件夹时,我会在终端的输出选项卡中看到这个。

Tools environment: GOPATH=/Users/drexter/go
Installing 1 tool at /Users/drexter/go/bin in module mode.
  [email protected]

Installing golang.org/x/tools/[email protected] (/Users/drexter/go/bin/gopls) SUCCEEDED

All tools successfully installed. You are ready to Go. :)

字符串
which go给出“/usr/local/go/bin/go”
我没有设置goroot环境变量,所以我在终端中设置了go root export GOROOT=/Users/drexter/go/bin
printenv命令给出

...
GOPATH=/Users/drexter/go
GOROOT=/Users/drexter/go/bin
...


vscode settings.json -

"go.languageServerFlags": [

  ],
  "go.toolsManagement.autoUpdate": true,
  "editor.tabCompletion": "on",
  "go.installDependenciesWhenBuilding": true,
  "go.formatTool": "gofmt",
  "go.gopath": "~/go",
  "go.useLanguageServer": 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.lintTool": "golangci-lint",
  "go.delveConfig": {
  
  },
  // "go.goroot": "~go/bin",
  "editor.fontSize": 14,
  "[go]": {

    "editor.insertSpaces": false,
    "editor.formatOnSave": true,
    "editor.codeActionsOnSave": {
      "source.organizeImports": true
    }
  }


我也安装了go扩展。试过go nightly扩展。没有一个工作。
任何想法如何让去自动完成工作。

bxpogfeg

bxpogfeg1#

我在MacBook Air中运行Go,在我的.zshrc文件中有这样的配置:

export GOROOT=/usr/local/go/
export GOPATH=$HOME/go/
export PATH="${GOROOT}/bin:${PATH}"

字符串
对我来说很好。但是,这些变量取决于你安装Go的位置。

vybvopom

vybvopom2#

重新安装go后,

相关问题