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

debug: support no folder debugging

Open isidorn opened this issue 4 years ago • 4 comments

Hi VS Code PM here 👋

  1. Purple no folder VS Code -> create a new go file
  2. Press F5 -> notice how we offer the user to download your extension 👏
  3. Now the user presses F5 again and wants to debug, but nothing happens since go is 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

isidorn avatar Sep 24 '21 14:09 isidorn

@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.

hyangah avatar Sep 24 '21 15:09 hyangah

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.

suzmue avatar Sep 24 '21 18:09 suzmue

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?)

hyangah avatar Sep 24 '21 18:09 hyangah

Sorry for the slow response.

  • It is great that you support no launch.json debugging 👏 I was not sure if you have this since I am not a Go user
  • You can detect if VS Code is running in no-folder mode by vscode.workspace.workspaceFolders, it will be undefined in 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 (like Python and js-debug). We would love if Go would also support debugging simple Go programs 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 😊

isidorn avatar Sep 28 '21 09:09 isidorn