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: go generate not working #41566

Closed
daxzhuo opened this issue Sep 23, 2020 · 8 comments
Closed

x/tools/gopls: go generate not working #41566

daxzhuo opened this issue Sep 23, 2020 · 8 comments
Assignees
Labels
Milestone

Comments

@daxzhuo
Copy link

@daxzhuo daxzhuo commented Sep 23, 2020

What version of Go, VS Code & VS Code Go extension are you using?

  • Run go version to get version of Go
    • 1.15.2
  • gopls version: v0.5.0
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders
    • 1.49.1
      58bb7b2331731bf72587010e943852e13e6fd3cf
      x64
  • Check your installed extensions to get the version of the VS Code Go extension
    • v0.17.0
  • Run go env to get the go development environment details

Share the Go related settings you have added/edited

"go.inferGopath": false,
"go.buildFlags": [
    "-o",
    "${workspaceRoot}/app/bin/app"
],
"go.formatTool": "goimports",
"go.toolsGopath": "D:\\go",
"go.lintTool": "golangci-lint",
"go.lintOnSave": "off",
"go.useLanguageServer": true,
"go.testFlags": [
    "-v"
],

Describe the bug

Click on go generate but nothing happen

Steps to reproduce the behavior:

  1. Create a go generate comment
  2. Click on go generate hint
  3. A tip show up and just disappear , nothing happen

Screenshots or recordings

image
image

@stamblerre stamblerre transferred this issue from golang/vscode-go Sep 23, 2020
@stamblerre stamblerre changed the title go generate not working x/tools/gopls: go generate not working Sep 23, 2020
@gopherbot gopherbot added this to the Unreleased milestone Sep 23, 2020
@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Sep 23, 2020

@daxzhuo: What is your gopls version? Also, can you please share your gopls logs when you see this happen? Information on how to capture logs can be found here: https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md#capturing-logs.

@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.5.1 Sep 23, 2020
@daxzhuo
Copy link
Author

@daxzhuo daxzhuo commented Sep 23, 2020

@stamblerre gopls: v0.5.0
I don't think that's relevant, and also there is no log printed by gopls too.

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Sep 23, 2020

The logs should be found by navigating to View -> Output -> Tasks -> gopls (server)). You will also need to add "go.languageServerFlags": ["-rpc.trace"] to your VS Code Go settings to get detailed logs.

@daxzhuo
Copy link
Author

@daxzhuo daxzhuo commented Sep 23, 2020

[Trace - 11:33:34.654 AM] Sending request 'workspace/executeCommand - (18)'.
Params: {"command":"generate","arguments":["file:///D:/app/mocks/service",false]}
[Trace - 11:33:34.654 AM] Received request 'window/workDoneProgress/create - (5)'.
Params: {"token":"8674665223082153551"}
[Trace - 11:33:34.655 AM] Sending response 'window/workDoneProgress/create - (5)' in 0ms.
Result:
[Trace - 11:33:34.655 AM] Received notification '$/progress'.
Params: {"token":"8674665223082153551","value":{"kind":"begin","title":"Run go generate","cancellable":true,"message":"Running..."}}
[Trace - 11:33:34.655 AM] Received response 'workspace/executeCommand - (18)' in 0ms.
Result: null
[Trace - 11:33:35.119 AM] Received notification '$/progress'.
Params: {"token":"8674665223082153551","value":{"kind":"end","message":"generate: completed"}}
[Trace - 11:33:53.014 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/09/23 11:33:53 background imports cache refresh starting\n"}
[Info - 11:33:53 AM] 2020/09/23 11:33:53 background imports cache refresh starting

@daxzhuo
Copy link
Author

@daxzhuo daxzhuo commented Sep 23, 2020

It work with PS D:\app> go generate D:/app/mocks/service though.

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Sep 23, 2020

Thanks for sharing the logs. It doesn't look like there are any error messages logged or reported. Are you able to reproduce this issue in a public repository so that we can try to reproduce?

/cc @findleyr

@findleyr
Copy link
Contributor

@findleyr findleyr commented Sep 23, 2020

I think I'm able to reproduce: it appears the generate command is not correctly handling its directory argument. I presume that's what's happening here.

Fix incoming.

@findleyr findleyr self-assigned this Sep 23, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Sep 23, 2020

Change https://golang.org/cl/256818 mentions this issue: internal/lsp: fix go generate command for subdirs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants