10

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?

Serve Laurijssen
  • 9,266
  • 5
  • 45
  • 98
  • I don’t use vs code, but I would try https://medium.com/average-coder/how-to-debug-a-running-go-app-with-vscode-76e3eac45bd and https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl – georgeok Jul 04 '19 at 19:52
  • thanks, tried it for a few hours again but couldnt get it working yet. Not sure why but it seems to have something to do with VSCode messing up the cwd of the go program itself in WSL – Serve Laurijssen Jul 05 '19 at 10:11
  • Hi, I am also facing similar issue. Not able to connect to Delve debugger. the debugger console shows API server listening at: 127.0.0.1:2345 but nothing after that. Were you able to debug with Goland ? – Nikhil Mittal Jul 06 '19 at 20:40
  • No it's not working yet. Will try sometimes when I find the time – Serve Laurijssen Jul 08 '19 at 05:58
  • @NikhilMittal, I have the same issue, did you guys find out what is going on, are we missing something? – kuskmen Nov 07 '19 at 22:23
  • updated answer. Any time now that WSL2 is released – Serve Laurijssen Nov 08 '19 at 07:13

2 Answers2

3

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

Serve Laurijssen
  • 9,266
  • 5
  • 45
  • 98
1

If you can switch to WSL2, microsoft/vscode-go issue 2505 confirms:

Since WSL2 is working with this, I think we can close the bug

And WSL2 will be generally available in Windows 10, version 2004.
Windows 10 version 2004 is "20H1", because it's being released in the first half of the year 2020.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250