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

相关推荐
Tony Bai16 小时前
Go 1.26 :go mod init 默认行为的变化与 Go 版本管理的哲学思辨
开发语言·后端·golang
没有bug.的程序员21 小时前
IDEA 效能巅峰实战:自定义模板 Live Templates 内核、快捷键精密逻辑与研发提效深度指南
java·ide·intellij-idea·快捷键·研发提效·自定义模板
桂花很香,旭很美1 天前
[7天实战入门Go语言后端] Day 7:综合实战——小型 REST API 与优雅关闭
开发语言·后端·golang
桂花很香,旭很美1 天前
[7天实战入门Go语言后端] Day 6:测试与 Docker 部署——单元测试与多阶段构建
docker·golang·单元测试
charlie1145141911 天前
从0开始榨干 Claude Code:VSCode 实战配置与默认读取文件完整踩坑记录
ide·vscode·编辑器
secondyoung2 天前
Git使用:Git使用问题及解决方法总结
windows·经验分享·git·vscode·gitee·github·gitcode
遇见你的雩风2 天前
【Golang】--- Channel
开发语言·golang
Tony Bai2 天前
Go 1.26 中值得关注的几个变化:从 new(expr) 真香落地、极致性能到智能工具链
开发语言·后端·golang
桂花很香,旭很美2 天前
[7天实战入门Go语言后端] Day 5:中间件与业务分层——日志、鉴权与请求超时
开发语言·中间件·golang
聂 可 以2 天前
解决Pycharm中(Python)软件包下载速度很慢、甚至下载失败的问题
ide·python·pycharm