-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/tools/gopls: invalid errors when using "pkgm" VS Code snippet #39296
Comments
Thank you for filing a gopls issue! Please take a look at the Troubleshooting guide, and make sure that you have provided all of the relevant information here. |
Do you mind sharing the output of |
@stamblerre after reloading VSCode, the error disappears. But this is very annoying, when I meet issue like this, I have to reload VSCode. Or reopen go file. to make the error disappear. (in this case, reopen file doesn't work, I have to reload VSCode) |
I'm sorry, I understand this is frustrating behavior. Can you add this to your settings? "go.languageServerFlags": [
"-rpc.trace",
] This will enable verbose logging. If you're able to get a repro case and produce a shorter log, that would be really helpful in investigating the issue. |
@stamblerre here I get another error: "expected declaration, found o", but the go file is correct. gopls log: |
Here is a example that vscode or gopls stop working: my go file has error, but VSCode doesn't report it, even I reopen the go file. I have to reload VSCode |
the "expected declaration, found 'package'" error is very often, meet it again: |
Thank you for these reports. I was able to reproduce the issue in your first case, so I'll start with that. Seems like it's somehow tied to the |
@stamblerre the error also appears with cmd+a, cmd+x, cmd+v my vscode settings related: {
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 300,
"[golang]": {
"editor.tabSize": 4,
"editor.detectIndentation": false,
"editor.insertSpaces": false,
},
"go.delveConfig": {
"dlvLoadConfig": {
"followPointers": true,
"maxVariableRecurse": 1,
"maxStringLen": 100000,
"maxArrayValues": 1000,
"maxStructFields": -1
},
"apiVersion": 2,
"showGlobalVariables": true
},
"go.formatTool": "goimports",
"go.useLanguageServer": true,
"go.testFlags": [
"-v"
],
"go.languageServerFlags": [
"-rpc.trace",
],
"[go]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true,
},
},
"[go.mod]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true,
},
},
"gopls": {
"usePlaceholders": true,
"completeUnimported": true
},
} |
Thanks - that's already filed as #38424. |
@stamblerre change package name cause the "(no package for import fmt)compiler |
the gopls stop working again, no error is shown for my file, I have to reload VSCode: It's very unstable. |
just now I meet two new errors:
in the meantime I am upgrading go using brew, but when the upgrade completes, the error is still there, I have to reload VSCode now |
@kzhui125: I appreciate you posting these comments and logs here, but it's difficult to make progress on them without clear repro cases. We will try to make progress on investigating as time permits, but we currently do have other priorities, so we may not get to triaging all of these. Regarding #39296 (comment), case (1) is #38403. In general, I would expect that you might need to restart the language server after updating |
I just confirmed that I can no longer reproduce the issues with the |
still have issue: |
Thanks for the log. This seems like a slightly different issue. In this case, I can reproduce by:
I know that @pjweinb has worked on improving the behavior when a package name changes. |
@kzhui125: Please explain the steps you took to encounter the error, if you are sharing a log. It is difficult to reproduce the problem with only the log, since it is quite long. |
|
Thanks for clarifying. That issue is already tracked here: #38424. |
Change https://golang.org/cl/241398 mentions this issue: |
* internal/lsp/lsprpc: improvements to daemon logging f2c07d7d * internal/lsp/regtest: simpler way to invert options cf799cae * internal/lsp: don't keep track of closed overlays 43ed9469 * internal/lsp: fix error in CL 242457 e66011cb * internal/lsp: clean up the code lens code a8f9df4c * internal/lsp: refactor generate code lens code c80dc571 * go/packages: add x test overlay test 130c9f19 * internal/lsp: add an importShortcut configuration ddb87c8c * internal/lsp: handle nil pointer in PackageStats 4cea8971 * internal/lsp/source: handle nil pointer in newBuiltinSignature b42590c1 * internal/lsp: avoid panic caused by assuming file ends with newline 9048b464 * internal/lsp: always show signature as the top line in hover 6acd2ab8 * gopls, internal/lsp: support an extra formatting hook for gofumpt 62a0bb78 * internal/lsp: add changeMethods logic to rename check f8240f79 * internal/lsp/source: add Vendor to list of supported commands 01425d70 * internal/analysisinternal: do not initialize {Get,Set}TypeErrors f739c553 * internal/lsp: watch go.{mod,sum} files, as well as Go files fd294ab1 * internal/lsp/cmd: add a -vv flag for higher verbosity 7342f973 * internal/lsp, go/packages: reproduce and fix golang/go#39646 f1c4188a * internal/lsp: add new go.mod requires to files with unused require 125cc70a * internal/lsp: fix rename with Windows line endings 55a0fde5 * internal/lsp/regtest: standardize on 20s timeout e327e101 * internal/lsp/regtest: use a common directory for regtest sandboxes e404ca24 * internal/lsp/regtest: remove stray short timeout df98bc6d * internal/lsp/regtest: add a regtest for golang/go#39296 3544e8c9 * internal/lsp/cache: handle missing mod file 31b9a748 * internal/lsp: check if analysis enabled in convenience fixes 7370b034 * internal/lsp/regtest: await IWL before running tests 134513de * internal/lsp/source: disable fillstruct by default d5a74533 * internal/lsp/cache: fix race in RunProcessEnvFunc 065b96d3 * internal/lsp: extract highlighted selection to variable 9c9572d6 * internal/imports: require valid options, move LocalPrefix up 416e8f4f * internal/lsp/analysis/fillstruct: support anonymous structs 9e0a013e * cmd/goyacc: print newlines more consistently b22de682 * all: update dependencies in go.mod file 682c4542 * internal/lsp/source: handle nil pointer in comment completions 95bc2bdf
* internal/lsp: add a configuration to enable/disable links in hover 6ddee643 * internal/lsp: log errors for compute fix edits instead of returning d518495e * internal/lsp: refactor go.mod diagnostics to simplify the API 58eba7e7 * internal/lsp/lsprpc: improvements to daemon logging f2c07d7d * internal/lsp/regtest: simpler way to invert options cf799cae * internal/lsp: don't keep track of closed overlays 43ed9469 * internal/lsp: fix error in CL 242457 e66011cb * internal/lsp: clean up the code lens code a8f9df4c * internal/lsp: refactor generate code lens code c80dc571 * go/packages: add x test overlay test 130c9f19 * internal/lsp: add an importShortcut configuration ddb87c8c * internal/lsp: handle nil pointer in PackageStats 4cea8971 * internal/lsp/source: handle nil pointer in newBuiltinSignature b42590c1 * internal/lsp: avoid panic caused by assuming file ends with newline 9048b464 * internal/lsp: always show signature as the top line in hover 6acd2ab8 * gopls, internal/lsp: support an extra formatting hook for gofumpt 62a0bb78 * internal/lsp: add changeMethods logic to rename check f8240f79 * internal/lsp/source: add Vendor to list of supported commands 01425d70 * internal/analysisinternal: do not initialize {Get,Set}TypeErrors f739c553 * internal/lsp: watch go.{mod,sum} files, as well as Go files fd294ab1 * internal/lsp/cmd: add a -vv flag for higher verbosity 7342f973 * internal/lsp, go/packages: reproduce and fix golang/go#39646 f1c4188a * internal/lsp: add new go.mod requires to files with unused require 125cc70a * internal/lsp: fix rename with Windows line endings 55a0fde5 * internal/lsp/regtest: standardize on 20s timeout e327e101 * internal/lsp/regtest: use a common directory for regtest sandboxes e404ca24 * internal/lsp/regtest: remove stray short timeout df98bc6d * internal/lsp/regtest: add a regtest for golang/go#39296 3544e8c9 * internal/lsp/cache: handle missing mod file 31b9a748 * internal/lsp: check if analysis enabled in convenience fixes 7370b034 * internal/lsp/regtest: await IWL before running tests 134513de * internal/lsp/source: disable fillstruct by default d5a74533 * internal/lsp/cache: fix race in RunProcessEnvFunc 065b96d3 * internal/lsp: extract highlighted selection to variable 9c9572d6 * internal/imports: require valid options, move LocalPrefix up 416e8f4f * internal/lsp/analysis/fillstruct: support anonymous structs 9e0a013e * cmd/goyacc: print newlines more consistently b22de682 * all: update dependencies in go.mod file 682c4542 * internal/lsp/source: handle nil pointer in comment completions 95bc2bdf
* internal/lsp: add a configuration to enable/disable links in hover 6ddee643 * internal/lsp: log errors for compute fix edits instead of returning d518495e * internal/lsp: refactor go.mod diagnostics to simplify the API 58eba7e7 * internal/lsp/lsprpc: improvements to daemon logging f2c07d7d * internal/lsp/regtest: simpler way to invert options cf799cae * internal/lsp: don't keep track of closed overlays 43ed9469 * internal/lsp: fix error in CL 242457 e66011cb * internal/lsp: clean up the code lens code a8f9df4c * internal/lsp: refactor generate code lens code c80dc571 * go/packages: add x test overlay test 130c9f19 * internal/lsp: add an importShortcut configuration ddb87c8c * internal/lsp: handle nil pointer in PackageStats 4cea8971 * internal/lsp/source: handle nil pointer in newBuiltinSignature b42590c1 * internal/lsp: avoid panic caused by assuming file ends with newline 9048b464 * internal/lsp: always show signature as the top line in hover 6acd2ab8 * gopls, internal/lsp: support an extra formatting hook for gofumpt 62a0bb78 * internal/lsp: add changeMethods logic to rename check f8240f79 * internal/lsp/source: add Vendor to list of supported commands 01425d70 * internal/analysisinternal: do not initialize {Get,Set}TypeErrors f739c553 * internal/lsp: watch go.{mod,sum} files, as well as Go files fd294ab1 * internal/lsp/cmd: add a -vv flag for higher verbosity 7342f973 * internal/lsp, go/packages: reproduce and fix golang/go#39646 f1c4188a * internal/lsp: add new go.mod requires to files with unused require 125cc70a * internal/lsp: fix rename with Windows line endings 55a0fde5 * internal/lsp/regtest: standardize on 20s timeout e327e101 * internal/lsp/regtest: use a common directory for regtest sandboxes e404ca24 * internal/lsp/regtest: remove stray short timeout df98bc6d * internal/lsp/regtest: add a regtest for golang/go#39296 3544e8c9 * internal/lsp/cache: handle missing mod file 31b9a748 * internal/lsp: check if analysis enabled in convenience fixes 7370b034 * internal/lsp/regtest: await IWL before running tests 134513de * internal/lsp/source: disable fillstruct by default d5a74533 * internal/lsp/cache: fix race in RunProcessEnvFunc 065b96d3 * internal/lsp: extract highlighted selection to variable 9c9572d6 * internal/imports: require valid options, move LocalPrefix up 416e8f4f * internal/lsp/analysis/fillstruct: support anonymous structs 9e0a013e * cmd/goyacc: print newlines more consistently b22de682 * all: update dependencies in go.mod file 682c4542 * internal/lsp/source: handle nil pointer in comment completions 95bc2bdf
My go code is correct,
go run main.go
is successful, but VSCode with gopls often shows error.This is very annoying. the user experience is very bad .
Capture 20200528.mp4.zip
gopls logs
The text was updated successfully, but these errors were encountered: