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: formatting on save inserts an unnecessary package clause #38412

Closed
hyangah opened this issue Apr 13, 2020 · 2 comments
Closed
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

@hyangah
Copy link
Contributor

hyangah commented Apr 13, 2020

When using with VS Code

settings

gopls version 0.4.0
go1.14, darwin/amd64
VS Code Go extension 0.14.0-beta.6
go extension setting: "go.useLanguageServer": true,

how to repro:

$ cat main.go
package main
func main() { }

Open the it from the code, and save the file again (command+s). That triggers text edit like:

image

Attached the gopls log. code.log

File save was requested after the message 7.
So, message 8 is the one triggered by my action.

Note: when triggering the formatting using "Format Document" (e.g. right click -> "Format Document") the formatting works as expected.

@gopherbot gopherbot added this to the Unreleased milestone Apr 13, 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 Apr 13, 2020
@stamblerre
Copy link
Contributor

Thanks for the report! Looks like this is caused by the codeAction (import organization). I know that it adds a fake package clause if it doesn't find one, but this doesn't seem to be that. I'll investigate.

@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.5.0 Apr 13, 2020
@gopherbot
Copy link

Change https://golang.org/cl/228264 mentions this issue: internal/lsp: fix imports issue with duplicate package decl

@stamblerre stamblerre modified the milestones: gopls/v0.5.0, gopls/v0.4.1 May 13, 2020
@golang golang locked and limited conversation to collaborators May 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