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: don't load invalid build configurations unless they contain Go code #43093

Closed
andypwarren opened this issue Dec 9, 2020 · 12 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.

Comments

@andypwarren
Copy link

Gopls is running very slowly in vscode when inside a workspace

What did you do?

Opened up a vscode workspace, waited for Go extension to initialise and started typing.

What did you expect to see?

code completion results opening quickly

What did you see instead?

The red squiggly line moves very slowly across the word and the code completion results come up after a few seconds

Build info

golang.org/x/tools/gopls v0.5.5
    golang.org/x/tools/gopls@v0.5.5 h1:YBLs2WCwxx6mBF98Y6/mDIpKhP4Dt4Dz2q6LnMRBpDw=
    github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/google/go-cmp@v0.5.1 h1:JFrFEBb2xKufg6XkJsJr+WbKb4FQlURi5RUcBveYu9k=
    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-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck=
    golang.org/x/tools@v0.0.0-20201204180437-c46b611624b3 h1:uxH+MECLNmX/vsPe4txyeQ1LCmhdUxf7p4hjkHexg+c=
    golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
    honnef.co/go/tools@v0.0.1-2020.1.6 h1:W18jzjh8mfPez+AwGLxmOImucz/IFjpNlrKVnaj2YVc=
    mvdan.cc/gofumpt@v0.0.0-20200927160801-5bfeb2e70dd6 h1:z+/YqapuV7VZPvBb3GYmuEJbA88M3PFUxaHilHYVCpQ=
    mvdan.cc/xurls/v2@v2.2.0 h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A=
@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 Dec 9, 2020
@gopherbot gopherbot added this to the Unreleased milestone Dec 9, 2020
@stamblerre
Copy link
Contributor

Can you please share your gopls logs? Information on how to capture them can be found here.

@stamblerre stamblerre modified the milestones: Unreleased, gopls/unplanned Dec 9, 2020
@stamblerre stamblerre added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Dec 9, 2020
@stamblerre stamblerre changed the title x/tools/gopls: Running very slowly in VSCode workspace x/tools/gopls: running very slowly in VSCode workspace Dec 9, 2020
@andypwarren
Copy link
Author

This is the log result when I type errors into a Go file. The file has around 500 lines of Go code and the workspace has 11 directories, 5 of which are Go projects, using modules.
gopls-logs.log

@stamblerre
Copy link
Contributor

It looks like gopls cannot find the go.mod files for these different directories--where are the go.mod files located and how is your workspace set up? Also, if possible, can you please make sure your log starts from the very beginning (the initialize request) because that includes more relevant debug information. Thanks!

@andypwarren
Copy link
Author

Hi @stamblerre Thanks for taking the time to investigate this. All the go.mod files are located in the root of their respective directories e.g.

├── contentsvc
│   ├── go.mod
├── graphql
│   ├── go.mod

The workspace was setup awhile ago using the Add folder to workspace action. I've been using previous releases of gopls for a while without this issue.
gopls-log-init.log

@stamblerre
Copy link
Contributor

It looks like gopls is struggling with the following directories:

/Users/andy/p1/charts
/Users/andy/p1/configs
/Users/andy/p1/admin
/Users/andy/p1/frontend
/Users/andy/p1/terraform

Are these modules / do they contain Go code?

@andypwarren
Copy link
Author

No those directories don't contain any Go code.

@stamblerre stamblerre changed the title x/tools/gopls: running very slowly in VSCode workspace x/tools/gopls: don't load invalid build configurations unless they contain Go code Dec 10, 2020
@stamblerre stamblerre removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Dec 10, 2020
@stamblerre
Copy link
Contributor

It looks like gopls is finding packages in those directories. Can you try running go list -e -json -compiled ./ in /Users/andy/p1/charts or any of those other directories?

@andypwarren
Copy link
Author

That command returns "Err": "no Go files in /Users/andy/p1/charts" and is the same for all the other none Go directories.

Heres the full output

{
	"Dir": "/Users/andy/p1/charts",
	"ImportPath": "_/Users/andy/p1/charts",
	"Match": [
		"./charts"
	],
	"Incomplete": true,
	"Error": {
		"ImportStack": [
			"./charts"
		],
		"Pos": "",
		"Err": "no Go files in /Users/andy/p1/charts"
	}
}

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/277114 mentions this issue: internal/lsp/cache: filter packages before logging their count

@stamblerre
Copy link
Contributor

After some further investigation, it looks like we aren't actually processing these packages with no Go files. However, it may aid in investigation if you can try setting GO111MODULE=on explicitly in your environment. Does that change the outcome at all?

@andypwarren
Copy link
Author

Unfortunately the issue remained after setting GO111MODULE. However, I've upgraded to version 0.6.0 and the issue seems to have been resolved. It's much more performant now using the same workspace.

@stamblerre
Copy link
Contributor

Glad to hear that the issue is resolved. I'll go ahead and close this then.

@stamblerre stamblerre removed this from the gopls/v1.0.0 milestone Dec 23, 2020
@golang golang locked and limited conversation to collaborators Dec 23, 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