我已经在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扩展。没有一个工作。
任何想法如何让去自动完成工作。
2条答案
按热度按时间bxpogfeg1#
我在MacBook Air中运行Go,在我的.zshrc文件中有这样的配置:
字符串
对我来说很好。但是,这些变量取决于你安装Go的位置。
vybvopom2#
重新安装go后,