-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Closed
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.gopls/metadataIssues related to metadata loading in goplsIssues related to metadata loading in gopls
Milestone
Description
What version of Go, VS Code & VS Code Go extension are you using?
Version Information
- Run
go versionto get version of Go from the VS Code integrated terminal.- go version go1.17.2 darwin/amd64
- Run
gopls -v versionto get version of Gopls from the VS Code integrated terminal.- golang.org/x/tools/gopls v0.7.3
golang.org/x/tools/gopls@v0.7.3 h1:Lru57ht8vtDMouRskFC085VAjBAZRAISd/lwvwOOV0Q=
github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/google/go-cmp@v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
golang.org/x/mod@v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
golang.org/x/sync@v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
golang.org/x/sys@v0.0.0-20210809222454-d867a43fc93e h1:WUoyKPm6nCo1BnNUvPGnFG3T5DUVem42yDJZZ4CNxMA=
golang.org/x/text@v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
golang.org/x/tools@v0.1.8-0.20211014194737-fc98fb2abd48 h1:hk7xRoeg0CG1nRLsd5BZLDUgVpA9bnKylGk1p2/BPH0=
golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
honnef.co/go/tools@v0.2.0 h1:ws8AfbgTX3oIczLPNPCu5166oBg9ST2vNs0rcht+mDE=
mvdan.cc/gofumpt@v0.1.1 h1:bi/1aS/5W00E2ny5q65w9SnKpWEF/UIOqDYBILpo9rA=
mvdan.cc/xurls/v2@v2.3.0 h1:59Olnbt67UKpxF1EwVBopJvkSUBmgtb468E4GVWIZ1I=
- golang.org/x/tools/gopls v0.7.3
- Run
code -vorcode-insiders -vto get version of VS Code or VS Code Insiders.- 1.61.2
6cba118ac49a1b88332f312a8f67186f7f3c1643
x64
- 1.61.2
- Check your installed extensions to get the version of the VS Code Go extension
- v0.28.1
-
Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) >
Go: Locate Configured Go Toolscommand.
Share the Go related settings you have added/edited
Settings
"gopls": { "buildFlags": [ "-tags=mage" ] }, "go.testFlags": [ "-count=1" ], "go-template.patterns": [ "*.tpl", "*.go.tpl", "**/*.tpl" ], "go.toolsManagement.autoUpdate": true,
Briefly, the problem is that vscode reports a slew of errors even though the code in the repo builds and runs with no errors or warnings from mage, go vet or go build.

The problem appears to be that vscode (via gopls) isn't honoring the //go:build mage directive in mypkg/magefile.go.
The complaints seems to originate because magefiles want to have package main specified.
I can make the vscode complaints go away by changing that to package mypkg, but then mage is no longer able to run.
I've used mage in this manner prior to the advent of go1.17 in large projects requiring extensive code generation without getting vscode complaints.
Steps to reproduce the behavior:
I've created a minimal example that reproduces the problem in a public repo.
git clone https://github.com/Michael-F-Ellis/magegopls
cd magegopls
code .- Observe list of errors in the
vscodeProblems tab. - Open terminal and run
go vet. Observe no problems reported. - If you have mage installed, run
mage -v - Observe that the code builds and runs with output similar to the following:
exec: mage -v generate
Running target: Generate
exec: go build
exec: ./magegopls
Generated at 2021-10-21 13:23:28.031119 -0400 EDT m=+0.000218297
bcbrockway
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.gopls/metadataIssues related to metadata loading in goplsIssues related to metadata loading in gopls