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: gopls does not rescan when using go generate #40661

Closed
henryas opened this issue Aug 10, 2020 · 9 comments
Closed

x/tools/gopls: gopls does not rescan when using go generate #40661

henryas opened this issue Aug 10, 2020 · 9 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@henryas
Copy link

henryas commented Aug 10, 2020

What did you do?

I opened the project in vscode. I tested the intellisense to make sure that gopls properly recognize the packages in the project and it did. I call go generate to regenerate some new files using the "run go generate ./..." link at the top of the go generate instruction.

What did you expect to see?

The intellisense should recognize the new files and update its information.

What did you see instead?

The intellisense fails to recognize the new files. I have to close and restart the vscode in order to get gopls to rescan the project.

Build info

golang.org/x/tools/gopls 0.4.4
    golang.org/x/tools/gopls@v0.4.4 h1:8djGYsaZ0ByP0vaXg4T+mnyfDcHpWKSZ+tpQSGv9ahk=
    github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/google/go-cmp@v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/mod@v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
    golang.org/x/sync@v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA=
    golang.org/x/tools@v0.0.0-20200729181040-64cdafbe085c h1:jLQLIAedRoS9I2Py7l/ZAGGzUxLFsdg42JXEpS/a+ow=
    golang.org/x/xerrors@v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
    honnef.co/go/tools@v0.0.1-2020.1.4 h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8=
    mvdan.cc/gofumpt@v0.0.0-20200709182408-4fd085cb6d5f h1:gi7cb8HTDZ6q8VqsUpkdoFi3vxwHMneQ6+Q5Ap5hjPE=
    mvdan.cc/xurls/v2@v2.2.0 h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A=

Go info

go version go1.14.7 windows/amd64

Gopls version

golang.org/x/tools/gopls 0.4.4
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Aug 10, 2020
@gopherbot gopherbot added this to the Unreleased milestone Aug 10, 2020
@stamblerre
Copy link
Contributor

Can you please share your gopls logs when this happens? Instructions on how to capture logs can be found here.

@stamblerre stamblerre modified the milestones: Unreleased, gopls/v1.0.0 Aug 10, 2020
@henryas
Copy link
Author

henryas commented Aug 10, 2020

[Info  - 12:34:18 PM] 2020/08/10 12:34:18 Build info
----------
golang.org/x/tools/gopls 0.4.4
    golang.org/x/tools/gopls@v0.4.4 h1:8djGYsaZ0ByP0vaXg4T+mnyfDcHpWKSZ+tpQSGv9ahk=
    github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/google/go-cmp@v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/mod@v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
    golang.org/x/sync@v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA=
    golang.org/x/tools@v0.0.0-20200729181040-64cdafbe085c h1:jLQLIAedRoS9I2Py7l/ZAGGzUxLFsdg42JXEpS/a+ow=
    golang.org/x/xerrors@v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
    honnef.co/go/tools@v0.0.1-2020.1.4 h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8=
    mvdan.cc/gofumpt@v0.0.0-20200709182408-4fd085cb6d5f h1:gi7cb8HTDZ6q8VqsUpkdoFi3vxwHMneQ6+Q5Ap5hjPE=
    mvdan.cc/xurls/v2@v2.2.0 h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A=

Go info
-------
go version go1.14.7 windows/amd64



[Info  - 12:34:19 PM] 2020/08/10 12:34:19 go env for C:\Users\Henry\Documents\Projects\Go Projects\bis
(root C:\Users\Henry\Documents\Projects\Go Projects\bis)
(valid build configuration = true)
(build flags: [])
GOPATH=C:\Users\Henry\Documents\Projects\Go
GOINSECURE=
GONOPROXY=github.com/henryas
GOPRIVATE=github.com/henryas
GONOSUMDB=github.com/henryas
GO111MODULE=
GOCACHE=C:\Users\Henry\AppData\Local\go-build
GOPROXY=https://proxy.golang.org,direct
GOSUMDB=sum.golang.org
GOFLAGS=
GOMOD=C:\Users\Henry\Documents\Projects\Go Projects\bis\go.mod
GOMODCACHE=
GOROOT=c:\go


[Info  - 12:34:21 PM] 2020/08/10 12:34:21 go/packages.Load
	snapshot=0
	directory=C:\Users\Henry\Documents\Projects\Go Projects\bis
	query=[./... builtin]
	packages=39

[Error - 12:34:41 PM] 2020/08/10 12:34:41 imports fixes: AllImportsFixes: C:\Users\Henry\Documents\Projects\Go Projects\bis\data\database\finance\invoice_note_repository.go:76:2: expected selector or type assertion, found 'return' (and 1 more errors)
	file="C:\\Users\\Henry\\Documents\\Projects\\Go Projects\\bis\\data\\database\\finance\\invoice_note_repository.go"

[Error - 12:34:45 PM] 2020/08/10 12:34:45 imports fixes: AllImportsFixes: C:\Users\Henry\Documents\Projects\Go Projects\bis\data\database\finance\invoice_note_repository.go:76:2: expected selector or type assertion, found 'return' (and 1 more errors)
	file="C:\\Users\\Henry\\Documents\\Projects\\Go Projects\\bis\\data\\database\\finance\\invoice_note_repository.go"

[Info  - 12:34:52 PM] 2020/08/10 12:34:52 background imports cache refresh starting

[Info  - 12:34:52 PM] 2020/08/10 12:34:52 background refresh finished after 50.952ms

[Error - 12:35:00 PM] 2020/08/10 12:35:00 imports fixes: AllImportsFixes: C:\Users\Henry\Documents\Projects\Go Projects\bis\data\database\finance\internal\invoice_note.go:95:15: expected ';', found s (and 3 more errors)
	file="C:\\Users\\Henry\\Documents\\Projects\\Go Projects\\bis\\data\\database\\finance\\internal\\invoice_note.go"

[Info  - 12:35:11 PM] 2020/08/10 12:35:11 mapgen Account JournalEntry JournalEntryDetail DepreciableAsset

	operation="generate"

[Info  - 12:35:11 PM] 2020/08/10 12:35:11 mapgen Company Invitation Member Role

	operation="generate"

[Info  - 12:35:11 PM] 2020/08/10 12:35:11 mapgen InvoiceNote InvoiceDetail

	operation="generate"

[Info  - 12:35:11 PM] 2020/08/10 12:35:11 mapgen Contact Item Warehouse Entry EntryDetail DeliveryNote DeliveryNoteDetail DeliveryReceipt DeliveryReceiptDetail TransferMemo TransferMemoDetail

	operation="generate"

[Info  - 12:35:12 PM] 2020/08/10 12:35:12 mapgen Resource

	operation="generate"

[Info  - 12:35:12 PM] 2020/08/10 12:35:12 mapgen Customer Product Order OrderDetail Return

	operation="generate"

[Info  - 12:35:12 PM] 2020/08/10 12:35:12 mapgen User

	operation="generate"

[Error - 12:35:23 PM] 2020/08/10 12:35:23 imports fixes: AllImportsFixes: C:\Users\Henry\Documents\Projects\Go Projects\bis\data\database\finance\invoice_note_repository.go:76:2: expected ';', found 'return' (and 1 more errors)
	file="C:\\Users\\Henry\\Documents\\Projects\\Go Projects\\bis\\data\\database\\finance\\invoice_note_repository.go"

[Info  - 12:35:24 PM] 2020/08/10 12:35:24 background imports cache refresh starting

[Info  - 12:35:24 PM] 2020/08/10 12:35:24 background refresh finished after 1.0513811s

[Error - 12:35:25 PM] 2020/08/10 12:35:25 imports fixes: AllImportsFixes: C:\Users\Henry\Documents\Projects\Go Projects\bis\data\database\finance\invoice_note_repository.go:76:2: expected selector or type assertion, found 'return' (and 1 more errors)
	file="C:\\Users\\Henry\\Documents\\Projects\\Go Projects\\bis\\data\\database\\finance\\invoice_note_repository.go"

[Error - 12:35:36 PM] 2020/08/10 12:35:36 imports fixes: AllImportsFixes: C:\Users\Henry\Documents\Projects\Go Projects\bis\data\database\finance\invoice_note_repository.go:76:2: expected selector or type assertion, found 'return' (and 1 more errors)
	file="C:\\Users\\Henry\\Documents\\Projects\\Go Projects\\bis\\data\\database\\finance\\invoice_note_repository.go"

@henryas
Copy link
Author

henryas commented Aug 10, 2020

I discovered gopls will update its database if you open the affected files in the editor. The affected files that are not opened do not get updated.

@stamblerre
Copy link
Contributor

@henryas: It looks like you didn't add the flags to increase the verbosity of your logs (https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md#vs-code). Do you mind adding those flags and then providing new logs? Sorry about that!

@henryas
Copy link
Author

henryas commented Aug 10, 2020

Sorry about that. It is my bad. Here we go. It is rather long, so I put it as an attachment.

log.txt

@stamblerre
Copy link
Contributor

Thank you for sharing that! I think we may be registering for didChangeWatchedFiles notifications incorrectly on Windows:

[Trace - 22:47:56.781 PM] Received request 'client/registerCapability - (2)'.
Params: {"registrations":[{"id":"workspace/didChangeConfiguration","method":"workspace/didChangeConfiguration"},{"id":"workspace/didChangeWorkspaceFolders","method":"workspace/didChangeWorkspaceFolders"},{"id":"workspace/didChangeWatchedFiles","method":"workspace/didChangeWatchedFiles","registerOptions":{"watchers":[{"globPattern":"C:\\Users\\Henry\\Documents\\Projects\\Go Projects\\bis/**/*.{go,mod,sum}","kind":7}]}}]}

Thank you for this report! I will try to reproduce this myself now.

@gopherbot
Copy link

Change https://golang.org/cl/247684 mentions this issue: internal/lsp: lowercase drive letters on Windows to fix file watching

@stamblerre
Copy link
Contributor

Just to keep track of these things -- I've filed microsoft/vscode#104387 as a result of this issue.

gopherbot pushed a commit to golang/tools that referenced this issue Aug 12, 2020
This is a work-around for
microsoft/vscode#104387. We now always
lowercase the drive letter on Windows.

This CL also fixes a bug introduced by CL 245327, which caused URIs
to be used instead of paths in the GlobPattern.

We really need VS Code integration tests for this
(golang/vscode-go#404).

Updates golang/go#40661

Change-Id: I21be6d929288cfe41168cea34001fc2f41ac6c8b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/247684
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
@stamblerre
Copy link
Contributor

I think this should be fixed in gopls at master. There are certainly remaining issues with gopls file watching in VS Code, but they're being tracked elsewhere. You can try gopls at master by running GO111MODULE=on go get golang.org/x/tools/gopls@master golang.org/x/tools@master.

@golang golang locked and limited conversation to collaborators Aug 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants