I have installed go in my mac. In vscode I have installed official go extension. But autocomplete doesn't work.
When I open a go folder I get this in output tab in terminal.
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
gives '/usr/local/go/bin/go'
I didn't have goroot env variable set. So I set go root export GOROOT=/Users/drexter/go/bin
in terminal.
printenv command gives
...
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
}
}
I also uninstalled and installed go extension. tried go nightly extension. None of them working.
Any Idea how to get go autocompletion working.
It worked after reinstalling go