Skip to content
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

Test explorer fails to resolve module name when the name does not appear on the first line in go.mod #2171

Closed
dlipovetsky opened this issue Apr 8, 2022 · 1 comment

Comments

@dlipovetsky
Copy link
Contributor

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.
    • go version go1.18 linux/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • ----------
      golang.org/x/tools/gopls v0.8.2
          golang.org/x/tools/gopls@v0.8.2 h1:+b7X2FDwmP7vxyYNOHe/ZFkecN5X8OtAgkNtuCr86wk=
          github.com/BurntSushi/toml@v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU=
          github.com/google/go-cmp@v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
          github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
          golang.org/x/mod@v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o=
          golang.org/x/sync@v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
          golang.org/x/sys@v0.0.0-20220209214540-3681064d5158 h1:rm+CHSpPEEW2IsXUib1ThaHIjuBVZjxNgSKmBLFfD4c=
          golang.org/x/text@v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
          golang.org/x/tools@v0.1.11-0.20220329213715-7cf6cf0fb5fd h1:vc69FAZNtE8951V+m/m3KwEZfMC599PHpNWdHuD7Awo=
          golang.org/x/vuln@v0.0.0-20220324005316-18fd808f5c7f h1:9dMzk88fnONra7zrEalqkRMGa9jMGf9B5mdzhYVyI28=
          golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
          honnef.co/go/tools@v0.2.2 h1:MNh1AVMyVX23VUHE2O27jm6lNj3vjO5DexS4A1xvnzk=
          mvdan.cc/gofumpt@v0.3.0 h1:kTojdZo9AcEYbQYhGuLf/zszYthRdhDNDUi2JKTxas4=
          mvdan.cc/xurls/v2@v2.4.0 h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=
      go: go1.18
      
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • e18005f0f1b33c29e81d732535d8c0e47cafb0b5
      x64
      
  • Check your installed extensions to get the version of the VS Code Go extension
    • v0.32.0
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
    • n/a

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

The current method to find the module name from the contents of go.mod fails if the module name does not appear on the first line. That can happen, for example, if the first line is comment. By comparison, the go list -m command does find the name.

Steps to reproduce the behavior:

  1. Create a new module, or use an existing module.
  2. Insert a comment // Example comment on the first line of the go.mod file.
  3. Save the go.mod file.
  4. Open the Test Explorer.
  5. Notice the error diaog "Failed to resolve tests" appears.
  6. Inspect the "Go" output to find the message Failed to resolve tests: TypeError: Cannot read properties of null (reading 'groups')

Screenshots or recordings

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

@gopherbot
Copy link
Collaborator

Change https://go.dev/cl/399074 mentions this issue: src/goTest: Use more robust method to find module name in go.mod

@suzmue suzmue modified the milestones: Untriaged, v0.33.0 Apr 8, 2022
@golang golang locked and limited conversation to collaborators Apr 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants