windows系统使用Vscode在WSL调试golang本地进程

背景:

windows10企业版

vscode+golang1.20

wsl编译运行。

vscode 使用本地wsl进行进程attach操作,发现:Access is denied.

本地进程启动,vscode调试进程。windows-Linux控制台:

bash 复制代码
Starting: C:\Users\book\go\bin\dlv.exe dap --listen=127.0.0.1:61732 from D:\test\job
DAP server listening at: 127.0.0.1:61732

表明:使用的是windows配置环境(dlv.exe)

解决方案:切换WSL环境:

  • 点击:><

  • 切换:

  • 显示:

    此时lauch.json运行使用的是wsl环境(dlv)

bash 复制代码
Starting: /home/book/go/bin/dlv dap --listen=127.0.0.1:63282 --log-dest=3 from /mnt/d/test/job
DAP server listening at: 127.0.0.1:63282
closing connection from different user (127.0.0.1:63284): connections to localhost are only accepted from the same UNIX user for security reasons
2024-02-27T17:08:35+08:00 error layer=dap Error accepting client connection: Only connections from the same user that started this instance of Delve are allowed to connect. See --only-same-user.
dlv dap (17665) exited with code: 0

报错原有是:用户不同

ref:

https://blog.csdn.net/qq_58307541/article/details/125738589

https://stackoverflow.com/questions/69442767/how-can-i-fix-the-vscode-debuger-in-vscode

相关推荐
南知意-9 小时前
IDEA 2026.1最新版安装教程
java·ide·intellij-idea·idea安装·idea激活
隔窗听雨眠11 小时前
Typora插件开发指南:从零打造IDE级写作环境
ide·typora
周杰伦的稻香11 小时前
Go + Redis:本地部署高性能图片主色调提取服务
开发语言·redis·golang
福大大架构师每日一题11 小时前
2026年6月TIOBE编程语言排行榜,Go语言排名第13,Rust语言排名12。关于Rust已进入平台期的报道似乎为时过早。
开发语言·golang·rust
专注_每天进步一点点12 小时前
IDEA中,Apifox Helper 的 2.0.15-243版本的插件 导出指定的接口,入参的中文名为空,描述为空
java·ide·intellij-idea
郝亚军13 小时前
如何在vscode上运行python程序
ide·vscode·编辑器
Arvin.Angela13 小时前
VsCode 安装文档
ide·vscode·编辑器
郝亚军13 小时前
Visual Studio 2022安装for C++桌面开发
c++·ide·visual studio
CAir214 小时前
copilot配置deepseek和skills
vscode·copilot·skill·deepseek