Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging Go code in Visual Studio Code WSL

I have a Visual Studio Code environment with the Linux Subsystem for windows running and it's compiling and running a Go project just fine.

Now I'm trying to get the delve debugger running following this link:

https://github.com/Microsoft/vscode-go/wiki/Debugging-Go-code-using-VS-Code

But I can't get it running, neither remote nor local.

Tried all kind of configurations in launch.json but breakpoints just arent hit and no error message is printed.

Has anyone got go debugging running on VSCode using the WSL?

like image 267
Serve Laurijssen Avatar asked Jul 03 '19 10:07

Serve Laurijssen


People also ask

How do I debug a WSL code in Visual Studio?

Debugging in WSL# Once you've opened a folder in WSL, you can use VS Code's debugger in the same way you would when running the application locally. For example, if you select a launch configuration in launch.json and start debugging (F5), the application will start on remote host and attach the debugger to it.

Can you use WSL in VS Code?

To get started with using WSL in VS Code, you'll need to download the WSL extension from the Extension Marketplace. You'll also need WSL and a Linux distribution installed. We recommend using WSL 2, which is the newest version of WSL, as you will benefit from significant performance advantages over WSL 1.


1 Answers

Old post, but its not possible to get delve to work on WSL

https://github.com/go-delve/delve/issues/1235

There was a better resource that explains fully why it doesnt work, cant find it now

Apparently it has something to do with WSL not implementing Linux fully...but it will in WSL2!

https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux

like image 101
Serve Laurijssen Avatar answered Sep 28 '22 20:09

Serve Laurijssen