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: duplicate unimported completions #41745

Closed
stamblerre opened this issue Oct 2, 2020 · 3 comments
Closed

x/tools/gopls: duplicate unimported completions #41745

stamblerre opened this issue Oct 2, 2020 · 3 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsFix The path to resolution is known, but the work has not been done. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@stamblerre
Copy link
Contributor

This is with the latest gopls, with the following settings:

{
	"go.useLanguageServer": true,
	"go.languageServerFlags": [
		"serve",
		"-rpc.trace",
		"--debug=localhost:6060",
	  ],
	"go.lintOnSave": "off",
	"go.buildOnSave": "off",
	"go.vetOnSave": "off",
	"gopls": {
		"staticcheck": true,
		"analyses": {		
			"fillreturns": true,
			"fillstruct": true,
		},
		"gofumpt": false,
		"linksInHover": true,
		"symbolStyle": "dynamic",
	},
	"[go]": {
		"editor.codeActionsOnSave": {
			"source.fixAll": true,
			"source.organizeImports": true,
		},		
		"editor.snippetSuggestions": "none",
	},
}

Confirmed that I don't have two goplses running, and I see the duplication in the logs.

[Trace - 22:30:46.541 PM] Received response 'textDocument/completion - (175)' in 9ms.
Result: {"isIncomplete":true,"items":[{"label":"Handle","kind":6,"detail":"(from \"net/http\")","preselect":true,"sortText":"00000","filterText":"Handle","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"Handle"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"Handle","kind":6,"detail":"(from \"net/http\")","sortText":"00001","filterText":"Handle","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"Handle"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"HandleFunc","kind":6,"detail":"(from \"net/http\")","sortText":"00002","filterText":"HandleFunc","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"HandleFunc"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"HandleFunc","kind":6,"detail":"(from \"net/http\")","sortText":"00003","filterText":"HandleFunc","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"HandleFunc"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"Handler","kind":6,"detail":"(from \"net/http\")","sortText":"00004","filterText":"Handler","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"Handler"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"Handler","kind":6,"detail":"(from \"net/http\")","sortText":"00005","filterText":"Handler","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"Handler"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"HandlerFunc","kind":6,"detail":"(from \"net/http\")","sortText":"00006","filterText":"HandlerFunc","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"HandlerFunc"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"HandlerFunc","kind":6,"detail":"(from \"net/http\")","sortText":"00007","filterText":"HandlerFunc","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"HandlerFunc"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"Head","kind":6,"detail":"(from \"net/http\")","sortText":"00008","filterText":"Head","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"Head"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"Head","kind":6,"detail":"(from \"net/http\")","sortText":"00009","filterText":"Head","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"Head"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"Header","kind":6,"detail":"(from \"net/http\")","sortText":"00010","filterText":"Header","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"Header"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"Header","kind":6,"detail":"(from \"net/http\")","sortText":"00011","filterText":"Header","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"Header"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"Hijacker","kind":6,"detail":"(from \"net/http\")","sortText":"00012","filterText":"Hijacker","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"Hijacker"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"Hijacker","kind":6,"detail":"(from \"net/http\")","sortText":"00013","filterText":"Hijacker","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"Hijacker"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"CanonicalHeaderKey","kind":6,"detail":"(from \"net/http\")","sortText":"00014","filterText":"CanonicalHeaderKey","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"CanonicalHeaderKey"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"CanonicalHeaderKey","kind":6,"detail":"(from \"net/http\")","sortText":"00015","filterText":"CanonicalHeaderKey","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"CanonicalHeaderKey"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"DefaultMaxHeaderBytes","kind":6,"detail":"(from \"net/http\")","sortText":"00016","filterText":"DefaultMaxHeaderBytes","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"DefaultMaxHeaderBytes"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"DefaultMaxHeaderBytes","kind":6,"detail":"(from \"net/http\")","sortText":"00017","filterText":"DefaultMaxHeaderBytes","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"DefaultMaxHeaderBytes"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"DefaultMaxIdleConnsPerHost","kind":6,"detail":"(from \"net/http\")","sortText":"00018","filterText":"DefaultMaxIdleConnsPerHost","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"DefaultMaxIdleConnsPerHost"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"DefaultMaxIdleConnsPerHost","kind":6,"detail":"(from \"net/http\")","sortText":"00019","filterText":"DefaultMaxIdleConnsPerHost","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"DefaultMaxIdleConnsPerHost"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"ErrAbortHandler","kind":6,"detail":"(from \"net/http\")","sortText":"00020","filterText":"ErrAbortHandler","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"ErrAbortHandler"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"ErrAbortHandler","kind":6,"detail":"(from \"net/http\")","sortText":"00021","filterText":"ErrAbortHandler","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"ErrAbortHandler"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"ErrHandlerTimeout","kind":6,"detail":"(from \"net/http\")","sortText":"00022","filterText":"ErrHandlerTimeout","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"ErrHandlerTimeout"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"ErrHandlerTimeout","kind":6,"detail":"(from \"net/http\")","sortText":"00023","filterText":"ErrHandlerTimeout","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"ErrHandlerTimeout"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"ErrHeaderTooLong","kind":6,"detail":"(from \"net/http\")","sortText":"00024","filterText":"ErrHeaderTooLong","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"ErrHeaderTooLong"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"ErrHeaderTooLong","kind":6,"detail":"(from \"net/http\")","sortText":"00025","filterText":"ErrHeaderTooLong","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"ErrHeaderTooLong"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"ErrHijacked","kind":6,"detail":"(from \"net/http\")","sortText":"00026","filterText":"ErrHijacked","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"ErrHijacked"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"ErrHijacked","kind":6,"detail":"(from \"net/http\")","sortText":"00027","filterText":"ErrHijacked","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"ErrHijacked"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"MethodHead","kind":6,"detail":"(from \"net/http\")","sortText":"00028","filterText":"MethodHead","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"MethodHead"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"MethodHead","kind":6,"detail":"(from \"net/http\")","sortText":"00029","filterText":"MethodHead","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"MethodHead"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"NotFoundHandler","kind":6,"detail":"(from \"net/http\")","sortText":"00030","filterText":"NotFoundHandler","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"NotFoundHandler"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"NotFoundHandler","kind":6,"detail":"(from \"net/http\")","sortText":"00031","filterText":"NotFoundHandler","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"NotFoundHandler"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"ParseHTTPVersion","kind":6,"detail":"(from \"net/http\")","sortText":"00032","filterText":"ParseHTTPVersion","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"ParseHTTPVersion"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"ParseHTTPVersion","kind":6,"detail":"(from \"net/http\")","sortText":"00033","filterText":"ParseHTTPVersion","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"ParseHTTPVersion"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"RedirectHandler","kind":6,"detail":"(from \"net/http\")","sortText":"00034","filterText":"RedirectHandler","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"RedirectHandler"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"RedirectHandler","kind":6,"detail":"(from \"net/http\")","sortText":"00035","filterText":"RedirectHandler","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"RedirectHandler"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"StateHijacked","kind":6,"detail":"(from \"net/http\")","sortText":"00036","filterText":"StateHijacked","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"StateHijacked"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"StateHijacked","kind":6,"detail":"(from \"net/http\")","sortText":"00037","filterText":"StateHijacked","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"StateHijacked"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"StatusEarlyHints","kind":6,"detail":"(from \"net/http\")","sortText":"00038","filterText":"StatusEarlyHints","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"StatusEarlyHints"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"StatusEarlyHints","kind":6,"detail":"(from \"net/http\")","sortText":"00039","filterText":"StatusEarlyHints","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"StatusEarlyHints"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"StatusHTTPVersionNotSupported","kind":6,"detail":"(from \"net/http\")","sortText":"00040","filterText":"StatusHTTPVersionNotSupported","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"StatusHTTPVersionNotSupported"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"StatusHTTPVersionNotSupported","kind":6,"detail":"(from \"net/http\")","sortText":"00041","filterText":"StatusHTTPVersionNotSupported","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"StatusHTTPVersionNotSupported"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"StatusRequestHeaderFieldsTooLarge","kind":6,"detail":"(from \"net/http\")","sortText":"00042","filterText":"StatusRequestHeaderFieldsTooLarge","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"StatusRequestHeaderFieldsTooLarge"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"StatusRequestHeaderFieldsTooLarge","kind":6,"detail":"(from \"net/http\")","sortText":"00043","filterText":"StatusRequestHeaderFieldsTooLarge","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"StatusRequestHeaderFieldsTooLarge"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"TimeoutHandler","kind":6,"detail":"(from \"net/http\")","sortText":"00044","filterText":"TimeoutHandler","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"TimeoutHandler"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]},{"label":"TimeoutHandler","kind":6,"detail":"(from \"net/http\")","sortText":"00045","filterText":"TimeoutHandler","insertTextFormat":2,"textEdit":{"range":{"start":{"line":14,"character":6},"end":{"line":14,"character":7}},"newText":"TimeoutHandler"},"additionalTextEdits":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"net/http\"\n"}]}]}

/cc @heschik @dandua98

Screen Shot 2020-10-01 at 10 30 19 PM

@stamblerre stamblerre added this to the gopls/v1.0.0 milestone Oct 2, 2020
@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 Oct 2, 2020
@dandua98
Copy link

dandua98 commented Oct 2, 2020

Was able to reproduce this with this code quite far back (even more than a couple of months ago), so this isn't recent. Surprised I never saw this happen before. Either way, I am not sure why this happens as of now and would need to dig in. Seems like an implementation detail that we never thought of.

@stamblerre stamblerre added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 2, 2020
@gopherbot
Copy link

Change https://golang.org/cl/259210 mentions this issue: internal/lsp/source: check for duplicate packages in unimported completion

@gopherbot
Copy link

Change https://golang.org/cl/261081 mentions this issue: internal/imports: dedupe import paths for standard library packages

@stamblerre stamblerre modified the milestones: gopls/v1.0.0, gopls/v0.5.2 Oct 13, 2020
@golang golang locked and limited conversation to collaborators Oct 13, 2021
@rsc rsc unassigned heschi Jun 23, 2022
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. NeedsFix The path to resolution is known, but the work has not been done. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants