Reputation: 119
I wonder if someone can share their best setup for Golang using Vscode on Mac. As I am continously having issues such as:
Your workspace is misconfigured: command-line-arguments has no metadata. Please see https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md for more information or file an issue (https://github.com/golang/go/issues/new) if you believe this is a mistake.
Here are some information of my go setup:
{
"window.zoomLevel": 1,
"workbench.iconTheme": "material-icon-theme",
"editor.accessibilitySupport": "off",
"go.useLanguageServer": true,
"go.formatTool": "gofmt",
"go.lintTool": "golangci-lint",
"[go]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
},
"explorer.confirmDragAndDrop": false,
"javascript.updateImportsOnFileMove.enabled": "always",
"diffEditor.ignoreTrimWhitespace": false
}
Upvotes: 3
Views: 16485
Reputation: 79
you can try this setting.
"go.inferGopath": false,
"go.buildOnSave": "workspace",
"go.lintOnSave": "package",
"go.vetOnSave": "package",
"go.buildTags": "",
"go.buildFlags": [],
"go.lintFlags": [],
"go.vetFlags": [],
"go.coverOnSave": false,
"go.useCodeSnippetsOnFunctionSuggest": false,
"go.formatTool": "goreturns",
"go.gocodeAutoBuild": false,
"go.useLanguageServer": true,
"go.alternateTools": {
"go-langserver": "gopls",
},
"go.languageServerExperimentalFeatures": {
"format": true,
"autoComplete": true
},
"[go]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
},
Upvotes: 5
Reputation: 6970
I'm seeing the same problem and also using golangci-lint
for a lint tool. When I look at the output from the Go extension (View > Command Pallet > Output: Focus on Output View; then choose "Go" in the dropdown for the output view), I see errors like this:
Error while running tool: /usr/local/bin/golangci-lint run --print-issued-lines=false
level=warning msg="[runner] Can't run linter goanalysis_metalinter: assign: failed prerequisites: [email protected]/pkg/example"
And this
level=error msg="Running error: buildssa: analysis skipped: errors in package: [/Users/tschaub/projects/pkg/example.go:6:15: undeclared name: SomethingIJustStartedTyping
The first error (assign: failed prerequisites
) was ticketed in https://github.com/golangci/golangci-lint/issues/827 and closed with a comment about updating to [email protected]
.
The second error (buildssa: analysis skipped
) was ticketed in https://github.com/golangci/golangci-lint/issues/896 and is receiving new comments as I type this.
Upgrading to v1.24.0 may not solve the issue, but it sounds like it might generate more descriptive output.
Even using [email protected]
doesn't fix the problem for me. I need to quit VSCode and restart it whenever I get in this "misconfigured" state. I'm hoping that after tools catch up with go modules, things will be a bit more stable/reliable.
Upvotes: 1