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

相关推荐
名字还没想好☜19 小时前
Go 的 time.Ticker 陷阱:定时任务里被忽略的内存泄漏与正确关闭
java·数据库·golang·go·定时器
灯澜忆梦1 天前
Go 语言 _JSON---序列化与反序列化
开发语言·golang·json
布朗克1681 天前
Go入门到精通-22-同步原语
开发语言·后端·golang·同步原语
信鸽爱好者1 天前
VSCode配置python虚拟环境路径
ide·vscode·python
爱吃提升1 天前
2026最新VSCode 详细下载安装教程+汉化教程(含快捷键与使用趋势)
ide·vscode·编辑器
五VV1 天前
VSCode_Markdown文件中自动公式编号设置的一种方法
ide·vscode·编辑器
怒放de生命20101 天前
【web3基础】go-zero使用etcd实现服务注册与发现(四)
golang·web3·etcd·go-zero
灯澜忆梦1 天前
Go语言_文件---文件操作
开发语言·后端·golang
Wang's Blog2 天前
Go-Zero项目开发4: 用户服务搜索、详情与统一错误处理
开发语言·golang
灯澜忆梦2 天前
GO_文件处理---字符串操作
开发语言·golang