Debugging Go code in Visual Studio Code WSL
Asked Answered
J

2

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?

Jonjona answered 3/7, 2019 at 10:37 Comment(6)
I don’t use vs code, but I would try medium.com/average-coder/… and marketplace.visualstudio.com/…Chitarrone
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 WSLJonjona
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 ?Treadway
No it's not working yet. Will try sometimes when I find the timeJonjona
@NikhilMittal, I have the same issue, did you guys find out what is going on, are we missing something?Many
updated answer. Any time now that WSL2 is releasedJonjona
J
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

Jonjona answered 8/11, 2019 at 7:12 Comment(0)
P
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.

Pak answered 16/4, 2020 at 16:14 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.