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: add regtests for adding/deleting files #38407

Open
matthewmueller opened this issue Apr 13, 2020 · 7 comments
Open

x/tools/gopls: add regtests for adding/deleting files #38407

matthewmueller opened this issue Apr 13, 2020 · 7 comments

Comments

@matthewmueller
Copy link

@matthewmueller matthewmueller commented Apr 13, 2020

What version of Go are you using (go version)?

$ go version
go version go1.14.1 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/m/Library/Caches/go-build"
GOENV="/Users/m/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/m/Go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.14.1/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.14.1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/4f/tcxcr6_55v9bp38d8g4hjlf80000gn/T/go-build860054194=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I created a broken Go program 😬

https://play.golang.org/p/AGtHpgFoOts

What did you expect to see?

Proper syntax highlighting where I made my mistake.

In this case, func (*u Up) Run should be func (u *Up) Run

What did you see instead?

Nada. Nothing. Formatting fails, but that's about it.

image

If I go into the gopls logs on VSCode, I see the following:

[Error - 3:35:20 PM] Request textDocument/codeAction failed.
  Message: computing fix edits: /Users/m/Code/app/commands/migrate/migrate.go:20:7: expected identifier (and 1 more errors)
  Code: 0 
[Error - 3:35:20 PM] Request textDocument/formatting failed.
  Message: 20:7: expected identifier (and 1 more errors)
  Code: 0 
@gopherbot gopherbot added the gopls label Apr 13, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Apr 13, 2020

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.

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Apr 13, 2020

I'm not able to reproduce this - this is the error I see:

Screen Shot 2020-04-13 at 11 37 05 AM

What directory did you have open when you saw this? It's possible that if the file wasn't in the directory at the root of your workspace, then gopls didn't report diagnostics for it (something we will be fixing in gopls/v0.5.0).

If you still have the full logs for this, those would be helpful to see.

@stamblerre stamblerre changed the title gopls misses struct method syntax error in VSCode x/tools/gopls: unreported method syntax error Apr 13, 2020
@gopherbot gopherbot added this to the Unreleased milestone Apr 13, 2020
@gopherbot gopherbot added the Tools label Apr 13, 2020
@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.5.0 Apr 13, 2020
@matthewmueller
Copy link
Author

@matthewmueller matthewmueller commented Apr 14, 2020

Hey @stamblerre, thanks for the quick response!

I'm not quite up on the lingo for what a VSCode Workspace means, but here's my project's directory structure. I opened it with code .

.
├── commands
│   ├── migrate
│   └── web
├── controllers
│   ├── pages
│   └── users
├── go.mod
├── go.sum
├── internal
│   ├── env
│   └── log
├── main.go
├── migrate
│   └── migrate.go
└── views
    └── pages

The file with the syntax error is migrate/migrate.go.

I'm sadly not able to reproduce this issue reliably and I don't have the logs anymore. If I open VSCode fresh, it does properly show the error:

image

What I can say is that over time, as I'm adding and deleting files, it eventually stops reporting. It sounds like 0.5.0 might provide a solution for this issue? 😬🙏

Also let me know if you need more from me or if you already know what the issue is. I can try and create a better reproduction.

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Apr 14, 2020

Ah, ok so then it looks like your workspace is configured correctly and the diagnostics should be propagating. In the future when this happens, I'd suggest capturing detailed gopls logs (https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md#capturing-logs) so that we can see what sequence of edits led to this state.

The process of cache invalidations after adding and deleting files is not perfect yet, so it's likely that that was the cause. I will be adding more integration tests soon, so I'll retitle this issue to make sure I add a few cases for adding and deleting files.

@stamblerre stamblerre changed the title x/tools/gopls: unreported method syntax error x/tools/gopls: add regtests for adding / deleting files Apr 14, 2020
@stamblerre stamblerre changed the title x/tools/gopls: add regtests for adding / deleting files x/tools/gopls: add regtests for adding/deleting files Apr 14, 2020
@matthewmueller
Copy link
Author

@matthewmueller matthewmueller commented Apr 14, 2020

Okay sounds good. Do I also need to enable trace logs or is the default log output detailed enough?

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Apr 14, 2020

You'll want to add the -rpc.trace flag to go.languageServerFlags.

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Apr 16, 2020

Note to self: Another case to add a regression test for is microsoft/vscode-go#3179 (comment).

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
3 participants
You can’t perform that action at this time.