go: x/tools/gopls: spurious errors from template files (umbrella issue)

VSCode_error_in_packages_golang-1-17

What version of Go, VS Code & VS Code Go extension are you using?

Version Information
  • Run go version to get version of Go from the VS Code integrated terminal.
    • <Paste go version here>
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • <Paste gopls version here>
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • <Paste VS Code version here>
  • Check your installed extensions to get the version of the VS Code Go extension
    • <Paste Go extension version here>
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
    • <Paste the output here>

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file. Share all the settings with the go. or ["go"] or gopls prefixes.

Describe the bug

A clear and concise description of what the bug. A clear and concise description of what you expected to happen.

Steps to reproduce the behavior:

  1. Go to ‘…’
  2. Click on ‘…’
  3. See error

Screenshots or recordings

If applicable, add screenshots or recordings to help explain your problem.

I’m using Go 1.17 in Windows 10 64

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 19 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Development of Gitea is also affected by this. Is there any way of excluding linting of individual template files or even directories? We have some template files which aren’t even intended to be go templates and it’s even linting files within vendor and probably in node_modules.


Unfortunately:

"gopls": {
  "build.directoryFilters": ["-node_modules", "-nogopls/these/are/not/for/you"]
},

Is ignored by the template linter and disappointingly it seems like the only solution at present to prevent missing other more serious go errors is to simply turn off template linting through:

 "gopls": {
    "build.templateExtensions": [],
  },