vscode-go
vscode-go copied to clipboard
debug: support no folder debugging
Hi VS Code PM here 👋
- Purple no folder VS Code -> create a new
gofile - Press
F5-> notice how we offer the user to download your extension 👏 - Now the user presses
F5again and wants to debug, but nothing happens sincegois not supporting no folder debugging
Easiest to do this is to have a dynamic resolveDebugConfiguartion that will provide a launch configuration on the fly. Example
Apart from that consider contributing to the Editor title area menu, such that a Play button would appear in the Editor Title area (picture below). Example how to do this https://github.com/microsoft/vscode-mock-debug/blob/main/package.json#L80
I think both of these are super important and would really love that we improve this experience 💯
Let me know if I can help somehow. I am also open to a quick 30 min meeting where we can discuss about the new cool VS Code debug features that go could potentially adopt.
fyi @polinasok
@suzmue for debug integration
What is "no folder debugging"? We already provide resolveDebugConfiguration https://go.googlesource.com/vscode-go/+/refs/heads/master/src/goDebugConfiguration.ts#130 for users who work without launch.json.
If you are talking about debugging a file that is not stored anywhere, I am not sure if we can support that - since go and dlv work with files on disk only.
By default we build the directory, not just the open file, since a package is defined by the directory. If the directory doesn't contain a go.mod file then building the directory fails.
We could try to detect the lack of a go.mod file and then by default launch in file mode, or change the default completely.
I am afraid changing the default will hurt general no-configuration experience. @isidorn is there a way to detect whether the vscode is running in no-folder mode ? (maybe check the existence of workspace folders?)
Sorry for the slow response.
- It is great that you support no
launch.jsondebugging 👏 I was not sure if you have this since I am not aGouser - You can detect if VS Code is running in no-folder mode by
vscode.workspace.workspaceFolders, it will beundefinedin a no-folder mode. Keep in mind that a lot of VS Code users stay in no-folder vscode and there are some debuggers that support debugging in this scenario (likePythonandjs-debug). We would love ifGowould also support debugging simpleGoprograms here. - Consider the editor title area action. It really helps new users start debugging.
Let me know if you have more questions and I will be more responsive 😊