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/cmd/gopls: goimport and gofmt do not execute on save #33089

Closed
bobhancock opened this issue Jul 12, 2019 · 8 comments
Closed

x/tools/cmd/gopls: goimport and gofmt do not execute on save #33089

bobhancock opened this issue Jul 12, 2019 · 8 comments

Comments

@bobhancock
Copy link

@bobhancock bobhancock commented Jul 12, 2019

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

1.12.5

Does this issue reproduce with the latest release?

yes

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

Linu

What did you do?

@gopherbot gopherbot added this to the Unreleased milestone Jul 12, 2019
@gopherbot gopherbot added the gopls label Jul 12, 2019
@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Jul 14, 2019

Have you configured your settings according to https://github.com/golang/go/wiki/gopls? In particular,

"[go]": {
    "editor.formatOnSave": true,
    "editor.codeActionsOnSave": {
        "source.organizeImports": true
    }
},
@bobhancock
Copy link
Author

@bobhancock bobhancock commented Jul 14, 2019

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Jul 14, 2019

Do the other features work for you? Does formatting work if you right-click and "Format Document"? Can you share a gopls log? See https://github.com/golang/go/wiki/gopls#troubleshooting.

@bobhancock
Copy link
Author

@bobhancock bobhancock commented Jul 14, 2019

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Jul 14, 2019

Can you share a log from when you save and expect goimports to work? Note that you can set

"[go]": {
  "editor.codeActionsOnSaveTimeout": 3000
}

to increase the timeout for goimports, which may solve your problem.

@bobhancock
Copy link
Author

@bobhancock bobhancock commented Jul 14, 2019

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Jul 14, 2019

Based on these log messages, it seems like the response coming from gopls is correct. See the "newText" field of the response, which adds "fmt". This doesn't seem to be a gopls issue, but rather something to do with VSCode. It may be worth opening an issue with https://github.com/microsoft/vscode-go or https://github.com/microsoft/vscode-languageserver-node.

@bobhancock
Copy link
Author

@bobhancock bobhancock commented Jul 14, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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.