vscode-go icon indicating copy to clipboard operation
vscode-go copied to clipboard

Debug go generate

Open firelizzard18 opened this issue 4 years ago • 5 comments

Is your feature request related to a problem? Please describe. I am working on a generator. The generator has bugs that I need to debug.

Describe the solution you'd like When my code has a go generate comment starting with go run, as in go run ../my_generator, I want an additional code lens, debug go generate, to show up after the run go generate lens. This lens would start a debug session that executes the same code as the go run command.

Describe alternatives you've considered I've created a normal debug entry that runs my generator, but this is annoying when I am messing with flags. It would be really nice to have a lens to click on and totally forgo the launch configuration.

firelizzard18 avatar Jul 17 '21 23:07 firelizzard18

Thanks for the feature request @firelizzard18

go generate can take arbitrary commands that don't have to be go run commands. For example,

//go:generate goyacc -o gopher.go -p parser gopher.y

Do you mean debugging the go generate command itself, or the command go generate will run (in your example, my_generator package, maybe)?

For the latter, if handling commands that explicitly call go run is sufficient, I think it's feasible. The extension needs to detect the explicit invocation of go run ... and somehow implement go generate's command line parsing and populate a launch request.

hyangah avatar Jul 23 '21 16:07 hyangah

For the latter, if handling commands that explicitly call go run is sufficient, I think it's feasible.

That's the idea.

somehow implement go generate's command line parsing

What about go generate -n? That will print the commands that go generate would run, without running them, thus making it easy to use go generate's command line parsing directly.

firelizzard18 avatar Jul 23 '21 21:07 firelizzard18

Would love to see this.

ArpanSriv avatar Aug 30 '24 10:08 ArpanSriv

Change https://go.dev/cl/661195 mentions this issue: extension/src/goDebugConfiguration: fix debugging package urls

gopherbot avatar Mar 27 '25 02:03 gopherbot

I'm working on adding this to Go Companion. For now it's masquerading as a test adapter (for the Testing API). I've opened microsoft/vscode#244814 which would be the ideal solution, but if that doesn't look like it's going anywhere I'll probably make it opt-in and tell users they should manually hide it in the test explorer.

Image

firelizzard18 avatar Mar 27 '25 02:03 firelizzard18