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

x/tools/gopls: when using go.work in GOROOT, "gopls requires a module at the root of your workspace" #48022

Open
jayconrod opened this issue Aug 27, 2021 · 1 comment

Comments

@jayconrod
Copy link
Contributor

@jayconrod jayconrod commented Aug 27, 2021

ATTENTION: Please answer these questions BEFORE submitting your issue. Thanks!

What did you do?

  • Add the following go.work file in GOROOT:
go 1.18

directory (
	src
	src/cmd
)
  • Checkout a recent commit of Go. I was reviewing CL 345390, so this should get what I had:
git fetch https://go.googlesource.com/go refs/changes/90/345390/1 && git checkout FETCH_HEAD
  • Run make.bash, reload VSCode window (workspace root is GOROOT), open some files.
  • NOTE: this is my workspace settings.json, so I think gopls should be using cmd/go built in that GOROOT.
{
  "go.alternateTools": {
    "go": "/Users/jayconrod/Code/goroot/bin/go"
  }
}

What did you expect to see?

No errors, everything working normally.

What did you see instead?

On the VSCode status bar, I see a spinning arrow animation with the error:

gopls requires a module at the root of your workspace.
You can work with multiple modules by opening each one as a workspace folder.
Improvements to this workflow will be coming soon, and you can learn more here:
https://github.com/golang/tools/blob/master/gopls/doc/workspace.md.

I also see a red squiggly line with this error under the go directive in go.work. It also shows up on the package declaration in each .go file I open.

Build info

golang.org/x/tools/gopls v0.7.1
    golang.org/x/tools/gopls@v0.7.1 h1:Mh3Z8Xcoq3Zy7ksSlwDV/nzQSbjFf06A+L+F8YHq55U=
    github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/google/go-cmp@v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
    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-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE=
    golang.org/x/tools@v0.1.6-0.20210802203754-9b21a8868e16 h1:ZC/gVBZl8poJyKzWLxxlsmhayVGosF4mohR35szD5Bg=
    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.2.0 h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A=
@gopherbot gopherbot added this to the Unreleased milestone Aug 27, 2021
@jayconrod
Copy link
Contributor Author

@jayconrod jayconrod commented Aug 27, 2021

I normally see this error when working in GOROOT without go.work, but gopls seems to work fine otherwise, so I ignore it and hide the status bar so the error animation doesn't distract me. I don't think this should happen with a go.work file though.

@hyangah hyangah removed this from the Unreleased milestone Aug 30, 2021
@hyangah hyangah added this to the gopls/on-deck milestone Aug 30, 2021
@stamblerre stamblerre removed their assignment Oct 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants